fix(runtime): select the tree-shaking share plugin and test bundle contents - #5107
Open
ScriptedAlchemy wants to merge 19 commits into
Open
ScriptedAlchemy wants to merge 19 commits into
ScriptedAlchemy wants to merge 19 commits into
Conversation
Disabled handlers now expose the members callers use, so runtime-core typechecks without treating them as the enabled classes. Remote entry loading and the tree-shaking share plugin follow the same selectors and optimization defines as the other runtime modules.
🦋 Changeset detectedLatest commit: c813c4f The changes in this PR will be included in the next version bump. This PR includes changesets to release 48 packages
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
The disabled handler types were missing idToRemoteMap and getGlobalRemoteInfo, so the bridge-react build failed on the union.
@module-federation/devtools
@module-federation/cli
create-module-federation
@module-federation/dts-plugin
@module-federation/enhanced
@module-federation/error-codes
@module-federation/esbuild
@module-federation/managers
@module-federation/manifest
@module-federation/metro
@module-federation/metro-plugin-rnc-cli
@module-federation/metro-plugin-rnef
@module-federation/metro-plugin-rock
@module-federation/modern-js
@module-federation/modern-js-v3
@module-federation/native-federation-tests
@module-federation/native-federation-typescript
@module-federation/nextjs-mf
@module-federation/node
@module-federation/observability-plugin
@module-federation/playground
@module-federation/retry-plugin
@module-federation/rsbuild-plugin
@module-federation/rspack
@module-federation/rspress-plugin
@module-federation/rstest
@module-federation/runtime
@module-federation/runtime-core
@module-federation/runtime-tools
@module-federation/sdk
@module-federation/storybook-addon
@module-federation/third-party-dts-extractor
@module-federation/treeshake-frontend
@module-federation/treeshake-server
@module-federation/typescript
@module-federation/utilities
@module-federation/webpack-bundler-runtime
@module-federation/bridge-react
@module-federation/bridge-react-webpack-plugin
@module-federation/bridge-shared
@module-federation/bridge-vue3
@module-federation/inject-external-runtime-core-plugin
commit: |
The Webpack compile in the platform loader selector test exceeded Jest's 5 second limit on CI and was killed before it finished.
The selector checks now run the public function and the bundled program. They no longer pass by matching internal dist paths.
The selector checks only need the program result. Production minification did not finish before the test runner reached its limit, so the assertion never ran.
…nged The public getRemoteEntry export was gated by the #mf/remote-entry selector. webpack-bundler-runtime loads local tree-shaken shared fallbacks through it, so disableRemote broke shared loading for hosts with no remotes. The export now comes from utils/load again and the selector is deleted. Remote loading stays gated by the remote-module and remote-handler selectors. ModuleFederation typed its handler fields as the union of the enabled and disabled classes, which broke external access to enabled-only members. The fields keep the enabled class types and the constructor narrows once. DisabledSnapshotHandler rejects instead of throwing from a Promise-returning method and types manifestCache as Map<string, Manifest>. Tests cover the public loader under the no-remote condition with the define set, and the define picking the disabled or enabled remote handler.
…dler runtime The selector version of the tree-shaking share plugin returned early when bundlerRuntime was missing, which skipped the snapshot status patching that main performs without it. Only the shared getter wrapping needs bundlerRuntime, so the guard moves there. The container entry test asserts the disabled leaf has no export instead of matching a V8 error string, and the plugin test now reaches the bundler runtime guard with a shared fallback and a host snapshot present.
The webpack and Rspack bundle tests read the output bundle and assert that a marker string from the excluded module is absent, with the default bundle as the control: the remote module class under module-federation:no-remote and the Node script loader under module-federation:target-web.
# Conflicts: # packages/runtime-core/__tests__/remote-module-selector.spec.ts # packages/runtime-core/src/utils/load.ts # packages/sdk/__tests__/platform-loader-selector.spec.ts # packages/webpack-bundler-runtime/__tests__/container-entry-selector.spec.ts
# Conflicts: # packages/sdk/__tests__/platform-loader-selector.spec.ts
This was referenced Sep 25, 2026
This was referenced Sep 25, 2026
ScriptedAlchemy
force-pushed
the
rfc5036/06-docs-rollout
branch
from
September 26, 2026 04:59
6116bcb to
17531d7
Compare
ScriptedAlchemy
force-pushed
the
rfc5036/07-handler-contracts
branch
from
September 26, 2026 04:59
aa6f00b to
c813c4f
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of RFC #5036. An alternate proposal is open at #5128 with its own stack. This PR stays open until the decision on #5036 is made.
Stack: 7 of 7. Base: #5098 (
rfc5036/06-docs-rollout). Next: none.Landing order: #5093 → #5094 → #5095 → #5096 → #5097 → #5098 → #5107.
What changes
A
module-federation:no-sharedbuild now leaves out the tree-shaking share plugin, which used to bypass the package selectors. Default builds behave as onmain. The selector tests now check what a caller or a bundle sees instead of internaldistfile names.The plugin moves behind
#mf/tree-shaking-share-plugin. It still patchestreeShaking.statusfrom the host snapshot whenbundlerRuntimeis missing, as onmain, and only skips wrapping shared getters in that case.getRemoteInfoandgetRemoteEntryUniqueKeymove toutils/remoteInfo.ts.The public
getRemoteEntrybehavior is unchanged. It is not gated byFEDERATION_OPTIMIZE_NO_REMOTEor by a package condition, becausewebpack-bundler-runtimeloads local tree-shaken shared fallbacks through it even when a host has no remotes. Remote loading stays gated through the#mf/remote-moduleand#mf/remote-handlerselectors.The disabled handler changes that were here earlier now live in #5095, so that PR works on its own. This PR does not make the compiler pass
module-federation:*conditions.Verification
The branch history was rewritten on 2026-09-26 to remove attribution trailers from commit messages only. Every tree and patch is identical to the verified head;
c813c4fddis the rewritten tip.The
module-federation:no-remoteWebpack and Rspack bundles do not contain the remote module class marker, and the default bundles do.The
module-federation:target-webSDK bundles do not contain the Node loader marker, and the default bundles do.The disabled container entry module has no
initContainerEntryexport.The tree-shaking share plugin patches
treeShaking.statuswithout a bundler runtime and is left out undermodule-federation:no-shared.Locally, the runtime-core selector, handler, worker, image, and load suites passed 40 tests, the SDK selector suite 11, and the bundler-runtime selector suite 6. The
webpack-bundler-runtimeandbridge-reacttypechecks pass. Theruntime-coretypecheck passes apart from two existing errors inutils/preload.ts.CI at
c813c4fddpassed 20 checks, cancelled 2, and skipped 1. Lint Dependencies and pkg.pr.new Preview each ran twice on this commit. They setcancel-in-progress: trueper PR, so the second run cancelled the first about a second after it started. The second runs passed, and the cancelled runs were not rerun.e2e-treeshakewas skipped becausetools/scripts/ci-is-affected.mjsdid not select it. It has not run since feat(managers): resolve runtime families atomically #5093's head, so no end-to-end run covers the moved tree-shaking share plugin. The other end-to-end suites passed at this head, which builds the whole stack.Deviations from the RFC
None noted.
Overlaps with open PRs
File overlaps with 8 other open PRs
packages/runtime-core/src/utils/load.ts. This PR does not include that change.packages/webpack-bundler-runtime/src/init.ts. This PR does not include that change.packages/runtime-core/src/utils/load.ts. This PR does not include that change.packages/runtime-core/src/utils/load.ts. This PR does not include that change.packages/webpack-bundler-runtime/src/init.tsandpackages/webpack-bundler-runtime/tsconfig.lib.json. This PR does not include those changes.packages/webpack-bundler-runtime/src/init.tsandpackages/webpack-bundler-runtime/tsconfig.lib.json. This PR does not include those changes.packages/runtime-core/src/index.ts. This PR does not include that change.packages/webpack-bundler-runtime/src/init.tsandpackages/webpack-bundler-runtime/tsconfig.lib.json. This PR does not include those changes.