Skip to content

[codex] improve bundle size reporting for bundled runtime paths#4527

Merged
ScriptedAlchemy merged 20 commits intomainfrom
codex/bundle-size-report-retro
Mar 12, 2026
Merged

[codex] improve bundle size reporting for bundled runtime paths#4527
ScriptedAlchemy merged 20 commits intomainfrom
codex/bundle-size-report-retro

Conversation

@ScriptedAlchemy
Copy link
Copy Markdown
Member

@ScriptedAlchemy ScriptedAlchemy commented Mar 11, 2026

Summary

The bundle-size comment on codex/env-runtime-stacked was not showing the expected tree-shaking improvement because the existing report only measured each package's root entrypoint. That hid the ./bundler export path where the runtime split actually matters, and it also made the output look flat when comparing web vs node on the stacked base branch codex/runtime-bundler-entrypoints.

This change keeps the historical package-root metrics, but extends the report so the comment surfaces the runtime-specific signal directly.

What changed

  • keep the existing package dist, root ESM gzip, and root web/node bundle measurements
  • add tracked export-subpath measurement for ./bundler so tree-shakable runtime entrypoints are reported explicitly
  • add a Consumer scenarios section to the markdown output
  • add an Enhanced remoteEntry scenario that builds a tiny webpack consumer with @module-federation/enhanced and reports emitted remoteEntry gzip for web and node
  • keep compare-mode backward compatible when the base JSON does not contain the new scenario shape

Why this fixes the reporting gap

The runtime tree-shaking work in codex/env-runtime-stacked does not primarily show up in the root package import. It shows up in the ./bundler path and in downstream generated output. The new report exposes both:

  • tracked ./bundler totals across runtime packages
  • a downstream consumer-facing Enhanced remoteEntry comparison

In local CI parity, the updated report now includes:

  • tracked ./bundler totals
  • Consumer scenarios
  • Enhanced remoteEntry | web 19.2 kB | node 20.2 kB

Validation

Ran:

  • CI_LOCAL_BASE_REF=origin/codex/runtime-bundler-entrypoints pnpm run ci:local --only=bundle-size

Result:

  • job completed successfully
  • stats.txt included the new Consumer scenarios section
  • stats.txt included tracked ./bundler totals

Notes

Local validation was run with Node 22.22.0, while CI runs Node 20. The repository's local CI wrapper emitted that parity warning, but the bundle-size job completed successfully.

PR Stack

This PR is 3/3 in the stack.

Stack order (base -> tip):

  1. #4526 feat(runtime): expose bundler entrypoints (base)
  2. #4518 fix(enhanced,sdk,runtime): tree-shake env-target runtime paths
  3. #4527 [codex] improve bundle size reporting for bundled runtime paths (current, tip)

Navigation:

  • Prev: #4518
  • Next: none (this is the tip PR)
  • Stack refs: #4526 -> #4518 -> #4527
  • Branch: codex/bundle-size-report-retro into codex/env-runtime-stacked

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 11, 2026

⚠️ No Changeset found

Latest commit: 53f7b89

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 11, 2026

Open in StackBlitz

@module-federation/devtools

pnpm add https://pkg.pr.new/@module-federation/devtools@049a034

@module-federation/cli

pnpm add https://pkg.pr.new/@module-federation/cli@049a034

create-module-federation

pnpm add https://pkg.pr.new/create-module-federation@049a034

@module-federation/data-prefetch

pnpm add https://pkg.pr.new/@module-federation/data-prefetch@049a034

@module-federation/dts-plugin

pnpm add https://pkg.pr.new/@module-federation/dts-plugin@049a034

@module-federation/enhanced

pnpm add https://pkg.pr.new/@module-federation/enhanced@049a034

@module-federation/error-codes

pnpm add https://pkg.pr.new/@module-federation/error-codes@049a034

@module-federation/esbuild

pnpm add https://pkg.pr.new/@module-federation/esbuild@049a034

@module-federation/managers

pnpm add https://pkg.pr.new/@module-federation/managers@049a034

@module-federation/manifest

pnpm add https://pkg.pr.new/@module-federation/manifest@049a034

@module-federation/metro

pnpm add https://pkg.pr.new/@module-federation/metro@049a034

@module-federation/metro-plugin-rnc-cli

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rnc-cli@049a034

@module-federation/metro-plugin-rnef

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rnef@049a034

@module-federation/modern-js

pnpm add https://pkg.pr.new/@module-federation/modern-js@049a034

@module-federation/modern-js-v3

pnpm add https://pkg.pr.new/@module-federation/modern-js-v3@049a034

@module-federation/native-federation-tests

pnpm add https://pkg.pr.new/@module-federation/native-federation-tests@049a034

@module-federation/native-federation-typescript

pnpm add https://pkg.pr.new/@module-federation/native-federation-typescript@049a034

@module-federation/nextjs-mf

pnpm add https://pkg.pr.new/@module-federation/nextjs-mf@049a034

@module-federation/node

pnpm add https://pkg.pr.new/@module-federation/node@049a034

@module-federation/retry-plugin

pnpm add https://pkg.pr.new/@module-federation/retry-plugin@049a034

@module-federation/rsbuild-plugin

pnpm add https://pkg.pr.new/@module-federation/rsbuild-plugin@049a034

@module-federation/rspack

pnpm add https://pkg.pr.new/@module-federation/rspack@049a034

@module-federation/rspress-plugin

pnpm add https://pkg.pr.new/@module-federation/rspress-plugin@049a034

@module-federation/runtime

pnpm add https://pkg.pr.new/@module-federation/runtime@049a034

@module-federation/runtime-core

pnpm add https://pkg.pr.new/@module-federation/runtime-core@049a034

@module-federation/runtime-tools

pnpm add https://pkg.pr.new/@module-federation/runtime-tools@049a034

@module-federation/sdk

pnpm add https://pkg.pr.new/@module-federation/sdk@049a034

@module-federation/storybook-addon

pnpm add https://pkg.pr.new/@module-federation/storybook-addon@049a034

@module-federation/third-party-dts-extractor

pnpm add https://pkg.pr.new/@module-federation/third-party-dts-extractor@049a034

@module-federation/treeshake-frontend

pnpm add https://pkg.pr.new/@module-federation/treeshake-frontend@049a034

@module-federation/treeshake-server

pnpm add https://pkg.pr.new/@module-federation/treeshake-server@049a034

@module-federation/typescript

pnpm add https://pkg.pr.new/@module-federation/typescript@049a034

@module-federation/utilities

pnpm add https://pkg.pr.new/@module-federation/utilities@049a034

@module-federation/webpack-bundler-runtime

pnpm add https://pkg.pr.new/@module-federation/webpack-bundler-runtime@049a034

@module-federation/bridge-react

pnpm add https://pkg.pr.new/@module-federation/bridge-react@049a034

@module-federation/bridge-react-webpack-plugin

pnpm add https://pkg.pr.new/@module-federation/bridge-react-webpack-plugin@049a034

@module-federation/bridge-shared

pnpm add https://pkg.pr.new/@module-federation/bridge-shared@049a034

@module-federation/bridge-vue3

pnpm add https://pkg.pr.new/@module-federation/bridge-vue3@049a034

@module-federation/inject-external-runtime-core-plugin

pnpm add https://pkg.pr.new/@module-federation/inject-external-runtime-core-plugin@049a034

commit: 049a034

Base automatically changed from codex/env-runtime-stacked to main March 12, 2026 05:17
…ort-retro

# Conflicts:
#	.changeset/breezy-walls-burn.md
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 12, 2026

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 53f7b89
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/69b2631c73ae730008464f8e
😎 Deploy Preview https://deploy-preview-4527--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 12, 2026

Bundle Size Report

10 package(s) changed, 31 unchanged.

Package dist + ESM entry

Package Total dist (raw) Delta ESM gzip Delta
@changesets/assemble-release-plan 36.6 kB +1.0 kB (+2.9%) 2.2 kB -2221 B (-50.1%)
@module-federation/cli 26.7 kB no change 786 B no change
@module-federation/core 39.1 kB no change 173 B no change
@module-federation/enhanced 841.5 kB no change 712 B no change
@module-federation/managers 70.0 kB no change 334 B no change
@module-federation/manifest 138.4 kB no change 182 B no change
@module-federation/metro-plugin-rnc-cli 0 B no change 314 B no change
@module-federation/node 188.4 kB no change 217 B no change
@module-federation/storybook-addon 76.5 kB no change 100 B no change
@module-federation/utilities 110.6 kB no change 328 B no change

Bundle targets

Package Web bundle (gzip) Delta Node bundle (gzip) Delta
@changesets/assemble-release-plan 2.8 kB -353 B (-11.0%) 2.8 kB -353 B (-11.0%)
@module-federation/cli 2.3 kB -34 B (-1.4%) 2.3 kB -34 B (-1.4%)
@module-federation/core 1.1 kB -33 B (-2.9%) 1.0 kB -31 B (-2.9%)
@module-federation/enhanced 5.9 kB -59 B (-1.0%) 5.9 kB -59 B (-1.0%)
@module-federation/managers 2.4 kB -27 B (-1.1%) 2.4 kB -27 B (-1.1%)
@module-federation/manifest 6.2 kB -40 B (-0.6%) 6.2 kB -40 B (-0.6%)
@module-federation/metro-plugin-rnc-cli 411 B -27 B (-6.2%) 411 B -27 B (-6.2%)
@module-federation/node 9.2 kB -30 B (-0.3%) 9.2 kB -30 B (-0.3%)
@module-federation/storybook-addon 1.9 kB -25 B (-1.3%) 1.7 kB -25 B (-1.4%)
@module-federation/utilities 2.6 kB -33 B (-1.2%) 2.6 kB -33 B (-1.2%)

Consumer scenarios

Scenario Web output (gzip) Delta Node output (gzip) Delta Gap (node-web) Delta
Enhanced remoteEntry 19.1 kB -19 B (-0.1%) 20.1 kB -24 B (-0.1%) +1.0 kB -5 B

Total dist (raw): 10.68 MB (+1.0 kB (+0.0%))
Total ESM gzip: 70.9 kB (-2221 B (-3.0%))
Total web bundle (gzip): 161.4 kB (-661 B (-0.4%))
Total node bundle (gzip): 161.9 kB (-659 B (-0.4%))
Tracked ./bundler entry gzip: 556 B (no change)
Tracked ./bundler web bundle (gzip): 4.5 kB (no change)
Tracked ./bundler node bundle (gzip): 4.5 kB (no change)

Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as ./bundler are measured separately so ENV_TARGET-driven tree-shaking is visible. Bare imports are externalized to keep package-level sizes consistent, and assets are emitted as resources.

@ScriptedAlchemy ScriptedAlchemy marked this pull request as ready for review March 12, 2026 06:39
onlyUpdatePeerDependentsWhenOutOfRange,
}) {
//disable major bump due to peer dep
if (depType === 'peerDependencies') {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to preserve this in the updated version
if (depType === 'peerDependencies') { return false }

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c9c6285095

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +798 to +799
const changed = [...changedPackages].sort();
unchangedCount = allPackages.size - changed.length;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include scenario deltas in change summary

changed is derived only from changedPackages, which is populated from package and entrypoint metrics, so scenario-only diffs are ignored. When currentScenarios changes but package metrics do not, the report still prints No bundle size changes detected. even though the Consumer scenarios table shows deltas, which can hide real regressions/improvements in the top-level CI comment.

Useful? React with 👍 / 👎.

@ScriptedAlchemy ScriptedAlchemy merged commit 7fb1c23 into main Mar 12, 2026
9 of 10 checks passed
@ScriptedAlchemy ScriptedAlchemy deleted the codex/bundle-size-report-retro branch March 12, 2026 06:54
@2heal1 2heal1 mentioned this pull request Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant