Skip to content

fix(enhanced,sdk,runtime): tree-shake env-target runtime paths#4518

Merged
ScriptedAlchemy merged 11 commits intomainfrom
codex/env-runtime-stacked
Mar 12, 2026
Merged

fix(enhanced,sdk,runtime): tree-shake env-target runtime paths#4518
ScriptedAlchemy merged 11 commits intomainfrom
codex/env-runtime-stacked

Conversation

@ScriptedAlchemy
Copy link
Copy Markdown
Member

@ScriptedAlchemy ScriptedAlchemy commented Mar 10, 2026

Description

Build on the new runtime /bundler entrypoints to make the federation runtime path tree-shakeable, while preserving compatibility for older custom implementation overrides that still only expose dist/index.*.

This PR:

  • adds isBrowserEnvValue as an ENV_TARGET-aware static value in sdk
  • updates runtime-core and bridge-react call sites to use the static value where tree-shaking matters
  • switches enhanced and rspack runtime resolution to prefer /bundler
  • falls back to legacy dist/index.js and dist/index.cjs for older runtime-tools implementations
  • adds emitted-output coverage for the optimization experiment in enhanced
  • adds focused resolver coverage for rspack
  • adds a repo-local local-ci skill used for local CI parity runs in this checkout

Context

  • Original issue: #4452
  • Supersedes the closed predecessor: #4454
  • Bundle-size reporting changes from the old branch were split into: #4527

Test plan

  • pnpm --filter @module-federation/rspack test
  • pnpm --filter @module-federation/enhanced test
  • pnpm exec turbo run build --filter=@module-federation/runtime --filter=@module-federation/runtime-tools --filter=@module-federation/webpack-bundler-runtime --filter=@module-federation/enhanced --filter=@module-federation/rspack --force
  • pnpm run ci:local --only=build-and-test

PR Stack

This PR is 2/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 (current)
  3. #4527 [codex] improve bundle size reporting for bundled runtime paths (tip)

Navigation:

  • Prev: #4526
  • Next: #4527
  • Stack refs: #4526 -> #4518 -> #4527
  • Branch: codex/env-runtime-stacked into codex/runtime-bundler-entrypoints

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 10, 2026

🦋 Changeset detected

Latest commit: e0bd4d6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 45 packages
Name Type
@module-federation/bridge-react Major
@module-federation/sdk Major
@module-federation/runtime-core Major
@module-federation/modern-js-v3 Major
@module-federation/modern-js Patch
remote5 Patch
remote6 Patch
@module-federation/devtools Major
@module-federation/cli Major
@module-federation/data-prefetch Major
@module-federation/dts-plugin Major
@module-federation/enhanced Major
@module-federation/esbuild Patch
@module-federation/managers Major
@module-federation/manifest Major
@module-federation/metro Major
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/retry-plugin Major
@module-federation/rsbuild-plugin Major
@module-federation/rspack Major
@module-federation/rspress-plugin Major
@module-federation/runtime Major
@module-federation/storybook-addon Major
@module-federation/utilities Patch
@module-federation/webpack-bundler-runtime Major
@module-federation/bridge-react-webpack-plugin Major
@module-federation/bridge-vue3 Major
shared-tree-shaking-with-server-host Patch
shared-tree-shaking-with-server-provider Patch
shared-tree-shaking-no-server-host Patch
shared-tree-shaking-no-server-provider Patch
@module-federation/metro-plugin-rnc-cli Major
@module-federation/metro-plugin-rnef Major
node-dynamic-remote-new-version Patch
node-dynamic-remote Patch
website-new Patch
@module-federation/runtime-tools Major
@module-federation/inject-external-runtime-core-plugin Major
@module-federation/third-party-dts-extractor Major
@module-federation/bridge-shared Major
@module-federation/error-codes Major
create-module-federation Major
@module-federation/treeshake-server Major
@module-federation/treeshake-frontend Major

Not sure what this means? Click here to learn what changesets are.

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

@ScriptedAlchemy ScriptedAlchemy changed the title fix(sdk,runtime): stabilize env detection and internal env usage fix(sdk,runtime): isolate ENV_TARGET-aware env detection updates Mar 10, 2026
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: 51ba4b70e2

ℹ️ 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".

@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@fe04e38

@module-federation/cli

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

create-module-federation

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

@module-federation/data-prefetch

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

@module-federation/dts-plugin

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

@module-federation/enhanced

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

@module-federation/error-codes

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

@module-federation/esbuild

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

@module-federation/managers

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

@module-federation/manifest

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

@module-federation/metro

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

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

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

@module-federation/metro-plugin-rnef

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

@module-federation/modern-js

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

@module-federation/modern-js-v3

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

@module-federation/native-federation-tests

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

@module-federation/native-federation-typescript

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

@module-federation/nextjs-mf

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

@module-federation/node

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

@module-federation/retry-plugin

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

@module-federation/rsbuild-plugin

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

@module-federation/rspack

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

@module-federation/rspress-plugin

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

@module-federation/runtime

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

@module-federation/runtime-core

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

@module-federation/runtime-tools

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

@module-federation/sdk

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

@module-federation/storybook-addon

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

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

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

@module-federation/treeshake-frontend

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

@module-federation/treeshake-server

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

@module-federation/typescript

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

@module-federation/utilities

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

@module-federation/webpack-bundler-runtime

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

@module-federation/bridge-react

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

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

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

@module-federation/bridge-shared

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

@module-federation/bridge-vue3

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

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

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

commit: fe04e38

Base automatically changed from codex/bundle-size-split to main March 11, 2026 03:49
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 11, 2026

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 634d0a7
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/69b1173cf7f53b00084275c8
😎 Deploy Preview https://deploy-preview-4518--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 11, 2026

Bundle Size Report

20 package(s) changed, 21 unchanged.

Package dist + public ESM exports

Package Total dist (raw) Delta Public ESM gzip Delta
@changesets/assemble-release-plan 26.1 kB -24812 B (-48.1%) 6.6 kB no change
@module-federation/bridge-react 357.8 kB +245 B (+0.1%) 7.3 kB +8 B (+0.1%)
@module-federation/bridge-vue3 140.8 kB +133 B (+0.1%) 21.5 kB +18 B (+0.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/devtools 4.80 MB -7913 B (-0.2%) 0 B no change
@module-federation/enhanced 841.5 kB -14 B (-0.0%) 1.8 kB no change
@module-federation/inject-external-runtime-core-plugin 5.4 kB +26 B (+0.5%) 548 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 243.9 kB no change 1.6 kB no change
@module-federation/metro-plugin-rnc-cli 0 B no change 314 B no change
@module-federation/modern-js 183.6 kB no change 11.8 kB no change
@module-federation/modern-js-v3 175.2 kB no change 11.3 kB no change
@module-federation/node 188.4 kB no change 4.6 kB no change
@module-federation/runtime 19.5 kB -13 B (-0.1%) 1.3 kB no change
@module-federation/runtime-core 249.4 kB +100 B (+0.0%) 509 B no change
@module-federation/sdk 108.4 kB +470 B (+0.4%) 1.3 kB +5 B (+0.4%)
@module-federation/storybook-addon 76.5 kB no change 1.1 kB 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 3.1 kB no change 3.1 kB no change
@module-federation/bridge-react 19.2 kB -32 B (-0.2%) 19.6 kB -176 B (-0.9%)
@module-federation/bridge-vue3 16.4 kB -156 B (-0.9%) 16.2 kB -999 B (-5.7%)
@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 -32 B (-3.0%)
@module-federation/devtools n/a n/a n/a n/a
@module-federation/enhanced 6.3 kB -61 B (-0.9%) 6.3 kB -61 B (-0.9%)
@module-federation/inject-external-runtime-core-plugin 405 B no change 405 B no change
@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 11.4 kB -54 B (-0.5%) 11.4 kB -53 B (-0.5%)
@module-federation/metro-plugin-rnc-cli 411 B -27 B (-6.2%) 411 B -27 B (-6.2%)
@module-federation/modern-js 7.0 kB -28 B (-0.4%) 7.0 kB -28 B (-0.4%)
@module-federation/modern-js-v3 6.8 kB -26 B (-0.4%) 6.8 kB -26 B (-0.4%)
@module-federation/node 13.2 kB -31 B (-0.2%) 13.1 kB -42 B (-0.3%)
@module-federation/runtime 958 B no change 958 B no change
@module-federation/runtime-core 13.6 kB +10 B (+0.1%) 13.4 kB +13 B (+0.1%)
@module-federation/sdk 4.8 kB -1 B (-0.0%) 5.7 kB -3 B (-0.1%)
@module-federation/storybook-addon 2.4 kB -26 B (-1.1%) 2.2 kB -26 B (-1.1%)
@module-federation/utilities 2.6 kB -33 B (-1.2%) 2.6 kB -33 B (-1.2%)

Total dist (raw): 10.67 MB (-31778 B (-0.3%))
Total ESM gzip: 118.3 kB (+31 B (+0.0%))
Total web bundle (gzip): 194.9 kB (-599 B (-0.3%))
Total node bundle (gzip): 195.4 kB (-1594 B (-0.8%))

Bundle sizes are generated with rslib (Rspack). Public ESM gzip aggregates explicit package export entry files (wildcard exports are ignored). Web/node bundles synthesize a single entry that imports those public ESM exports, set ENV_TARGET, and enable tree-shaking. Bare imports are externalized to keep sizes consistent with prior reporting, and assets are emitted as resources.

@ScriptedAlchemy ScriptedAlchemy force-pushed the codex/env-runtime-stacked branch from 6b4b44d to 634d0a7 Compare March 11, 2026 07:18
@ScriptedAlchemy ScriptedAlchemy changed the title fix(sdk,runtime): isolate ENV_TARGET-aware env detection updates fix(enhanced,sdk,runtime): tree-shake env-target runtime paths Mar 11, 2026
@ScriptedAlchemy ScriptedAlchemy changed the base branch from main to codex/runtime-bundler-entrypoints March 11, 2026 07:19
Base automatically changed from codex/runtime-bundler-entrypoints to main March 12, 2026 03:58
@ScriptedAlchemy ScriptedAlchemy merged commit c856ec1 into main Mar 12, 2026
20 checks passed
@ScriptedAlchemy ScriptedAlchemy deleted the codex/env-runtime-stacked branch March 12, 2026 05:17
@ScriptedAlchemy ScriptedAlchemy restored the codex/env-runtime-stacked branch March 12, 2026 05:18
@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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants