Skip to content

fix(runtime-core): fall back when runtime-infer share coverage misses - #8

Open
tonoizer wants to merge 28 commits into
mainfrom
cursor/fix-runtime-infer-share-coverage-afa3
Open

tonoizer wants to merge 28 commits into
mainfrom
cursor/fix-runtime-infer-share-coverage-afa3

Conversation

@tonoizer

@tonoizer tonoizer commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Description

shared[x].treeShaking.mode: 'runtime-infer' could serve another app's tree-shaken chunk when two non-singleton providers registered the same version with different exports. The consumer then threw on a missing export and never loaded the independent full fallback.

This change only uses a tree-shaken variant when the provider's offered exports (providedExports, else usedExports) cover the consumer. Otherwise it uses the full getter. Same-version registration also skips overwriting disjoint tree-shaken variants by app-name order. Webpack/Rspack init now stamps compiled usedExports onto provider treeShaking.providedExports when that list is present.

How to verify

pnpm exec turbo run test --filter=@module-federation/runtime-core --force

The new runtime-infer-share-coverage tests cover two same-version providers with disjoint exports in both app-name orders.

Related Issue

No tracked issue. Bug report: non-singleton runtime-infer same-version shares with disjoint exports loaded the wrong tree-shaken chunk.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.
Open in Web Open in Cursor 

ScriptedAlchemy and others added 28 commits September 7, 2026 11:11
…5069)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Co-authored-by: Hanric <hanric.zhang@gmail.com>
…ule-federation#5017)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: ScriptedAlchemy <zackary.l.jackson@gmail.com>
…ule-federation#5020)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: ScriptedAlchemy <zackary.l.jackson@gmail.com>
…ter-demo/router-remote4-2004 (module-federation#5041)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: ScriptedAlchemy <zackary.l.jackson@gmail.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com>
Co-authored-by: ScriptedAlchemy <zackary.l.jackson@gmail.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Hanric <hanric.zhang@gmail.com>
Co-authored-by: ScriptedAlchemy <zackary.l.jackson@gmail.com>
…5056)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com>
Co-authored-by: ScriptedAlchemy <zackary.l.jackson@gmail.com>
Moves the repo's @rspack/core, @rspack/cli and @rspack/dev-server to 2.x (core and cli 2.1.10, dev-server 2.2.1). The @module-federation/rspack peer range already accepts ^2.0.0-0. Demo apps drop experiments.css for a css/auto rule and turn off lazy compilation for remotes served by rspack serve.
…() (module-federation#5148)

esbuild reports metafile output paths relative to absWorkingDir. The plugin resolved them, and the manifest's shared package.json lookups, from process.cwd(), so a build with a different absWorkingDir failed with ENOENT on dist/remoteEntry.js or wrote its manifest next to the process. Builds that do not set absWorkingDir are unchanged.
…tion#5115)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Do not serve another app's tree-shaken shared chunk when its exports do
not cover the consumer. Prefer providedExports over usedExports, skip
unsafe same-version overwrites of disjoint variants, and stamp compiled
usedExports onto provider treeShaking.providedExports at init.
@github-actions

Copy link
Copy Markdown

Bundle Size Report

25 package(s) changed, 18 unchanged.

Package dist + ESM entry

Package Total dist (raw) Delta ESM gzip Delta
@module-federation/bridge-react 311.1 kB +2.5 kB (+0.8%) 1.5 kB -1 B (-0.1%)
@module-federation/bridge-vue3 193.3 kB +1.6 kB (+0.9%) 27.6 kB +269 B (+1.0%)
@module-federation/devtools 1.08 MB +79.4 kB (+7.7%) 4.1 kB +55 B (+1.3%)
@module-federation/dts-plugin 336.2 kB +812 B (+0.2%) 4.7 kB no change
@module-federation/enhanced 822.7 kB +2.3 kB (+0.3%) 672 B no change
@module-federation/esbuild 255.8 kB +692 B (+0.3%) 67 B no change
@module-federation/inject-external-runtime-core-plugin 5.2 kB +26 B (+0.5%) 518 B -1 B (-0.2%)
@module-federation/managers 70.7 kB no change 243 B -1 B (-0.4%)
@module-federation/modern-js 201.0 kB no change 1.2 kB +1 B (+0.1%)
@module-federation/native-federation-tests 93.3 kB +101 B (+0.1%) 745 B no change
@module-federation/native-federation-typescript 91.8 kB +101 B (+0.1%) 629 B no change
@module-federation/observability-plugin 480.8 kB +122 B (+0.0%) 150 B no change
@module-federation/playground 16.09 MB -13449471 B (-44.4%) 45.8 kB +165 B (+0.4%)
@module-federation/retry-plugin 44.3 kB +192 B (+0.4%) 2.9 kB no change
@module-federation/runtime 20.4 kB -13 B (-0.1%) 724 B no change
@module-federation/runtime-core 315.0 kB +4.5 kB (+1.4%) 570 B no change
@module-federation/storybook-addon 80.7 kB +299 B (+0.4%) 100 B no change
@module-federation/third-party-dts-extractor 20.1 kB +20 B (+0.1%) 2.0 kB no change
@module-federation/treeshake-frontend 626.5 kB -5 B (-0.0%) 0 B no change
@module-federation/treeshake-server 774.2 kB -5 B (-0.0%) 124 B no change
@module-federation/webpack-bundler-runtime 68.7 kB +605 B (+0.9%) 531 B no change

Bundle targets

Package Web bundle (gzip) Delta Node bundle (gzip) Delta
@module-federation/bridge-react 13.6 kB +120 B (+0.9%) 14.4 kB +114 B (+0.8%)
@module-federation/bridge-vue3 20.2 kB +211 B (+1.0%) 20.4 kB +223 B (+1.1%)
@module-federation/cli 2.3 kB -3 B (-0.1%) 2.4 kB -33 B (-1.3%)
@module-federation/core 1.0 kB -3 B (-0.3%) 1.0 kB -34 B (-3.1%)
@module-federation/devtools 30.3 kB -3 B (-0.0%) 30.3 kB -27 B (-0.1%)
@module-federation/enhanced 2.7 kB +6 B (+0.2%) 2.8 kB -44 B (-1.5%)
@module-federation/metro-plugin-rnc-cli 416 B -1 B (-0.2%) 435 B -26 B (-5.6%)
@module-federation/modern-js 5.1 kB +1 B (+0.0%) 5.1 kB +1 B (+0.0%)
@module-federation/node 9.1 kB +1 B (+0.0%) 9.1 kB -29 B (-0.3%)
@module-federation/playground 41.7 kB +174 B (+0.4%) 41.7 kB +174 B (+0.4%)
@module-federation/runtime-core 16.4 kB +217 B (+1.3%) 16.0 kB +215 B (+1.3%)
@module-federation/webpack-bundler-runtime 4.1 kB +27 B (+0.6%) 4.1 kB +27 B (+0.6%)

Tree-shakable entrypoints

Package Export Entry gzip Delta Web bundle (gzip) Delta Node bundle (gzip) Delta Gap (node-web) Delta
@module-federation/webpack-bundler-runtime ./bundler 151 B no change 4.1 kB +27 B (+0.6%) 4.1 kB +27 B (+0.6%) 0 B 0 B

Consumer scenarios

Scenario Web output (gzip) Delta Node output (gzip) Delta Gap (node-web) Delta
Enhanced remoteEntry 22.4 kB +139 B (+0.6%) 24.0 kB +124 B (+0.5%) +1.5 kB -15 B

Total dist (raw): 23.43 MB (-13354058 B (-35.2%))
Total ESM gzip: 111.9 kB (+487 B (+0.4%))
Total web bundle (gzip): 253.7 kB (+747 B (+0.3%))
Total node bundle (gzip): 256.0 kB (+561 B (+0.2%))
Tracked ./bundler entry gzip: 563 B (no change)
Tracked ./bundler web bundle (gzip): 4.9 kB (+27 B (+0.5%))
Tracked ./bundler node bundle (gzip): 4.9 kB (+27 B (+0.5%))

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.

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.

4 participants