feat(runtime): add package selectors for runtime capabilities - #5095
Open
ScriptedAlchemy wants to merge 18 commits into
Open
ScriptedAlchemy wants to merge 18 commits into
ScriptedAlchemy wants to merge 18 commits into
Conversation
🦋 Changeset detectedLatest commit: 9fb0f2f 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 |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
@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: |
ScriptedAlchemy
force-pushed
the
rfc5036/02-compiler-coordination
branch
from
September 18, 2026 15:36
8939c8c to
8cb38c9
Compare
ScriptedAlchemy
force-pushed
the
rfc5036/03-runtime-selectors
branch
from
September 18, 2026 15:40
dbe2d5a to
2d4f5e6
Compare
ScriptedAlchemy
force-pushed
the
rfc5036/02-compiler-coordination
branch
from
September 18, 2026 16:08
8cb38c9 to
5588bd3
Compare
Publish selector leaves in both module formats. Keep define behavior by default. Namespaced conditions remove disabled capabilities and Node loaders from compiler graphs.
ScriptedAlchemy
force-pushed
the
rfc5036/03-runtime-selectors
branch
from
September 18, 2026 16:09
2d4f5e6 to
1b84bc8
Compare
Treat Node package-import specifiers as package-local aliases instead of npm dependencies.
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.
These tests start Webpack and Rspack compiles. On CI the first compile takes longer than Jest's 5 second default while other package suites run, so the job stopped them before they asserted.
Declarations resolved `#mf/*` as external, so published .d.ts files kept the private specifiers. Consumers on `moduleResolution: node10` got TS2307, or `any` types with skipLibCheck. Declarations now inline the legacy leaf through tsconfig paths. Runtime JS keeps its `#mf/*` imports.
The worker leaf called `import(url)` without bundler ignore comments, so webpack and Rspack reported a critical dependency and built a context module for the remote URL.
Move the handler contract from the handler-contracts branch down to the selector branch. With remotes, shared, or snapshots disabled, the handlers now keep the hooks and methods the runtime and bridge-react call, so this branch works without the later one.
runtime-core reads a loaded remote entry from its global name. The worker loader returned the imported module without storing it there, so ESM remotes failed with RUNTIME-001.
CI sets FORCE_COLOR, so console.log in the child Node process colored numbers and booleans and the string assertions failed. The shared helper now drops FORCE_COLOR and sets NO_COLOR, and the SDK spec uses it.
The remote hooks moved to remote/hooks.ts, which imports the type itself.
This was referenced Sep 25, 2026
ScriptedAlchemy
force-pushed
the
rfc5036/02-compiler-coordination
branch
from
September 26, 2026 04:59
ef574ee to
d077ea1
Compare
ScriptedAlchemy
force-pushed
the
rfc5036/03-runtime-selectors
branch
from
September 26, 2026 04:59
5ca5c45 to
9fb0f2f
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: 3 of 7. Base: #5094 (
rfc5036/02-compiler-coordination). Next: #5096.Landing order: #5093 → #5094 → #5095 → #5096 → #5097 → #5098 → #5107.
What changes
A build that sets no
module-federation:*condition gets the same runtime exports and define behavior as today. A build that sets amodule-federation:no-*condition gets a disabled file, so the disabled code never enters the module graph. DefinePlugin can only delete it after parsing. Amodule-federation:target-*condition picks the SDK target. The compiler does not pass these conditions yet.The runtime packages add private selector files and keep their public exports. Runtime-core selects remote, shared, snapshot, preload, and helper modules. The bundler runtime selects container entry, remotes, and shared adapters. The SDK selects web, Node, worker, and universal targets. Each legacy, enabled, and disabled file is built for ESM and CommonJS. The enabled files are published for the upcoming positive conditions, and nothing selects them yet.
The worker loader uses
importScriptsandimport(). It stores an imported ESM remote under the remote's global name, as the Node loader does. Without that,getRemoteEntryfailed withRUNTIME-001.Disabled snapshot, shared, and remote handlers keep every member the runtime and
bridge-reactcall, such asloadRemoteSnapshotInfo,manifestCache,idToRemoteMap, theresolveSharehook, and the full remote hook set. The enabled and disabled remote handlers build their hooks from one function.ModuleFederationkeeps the enabled class types for its handler fields. This work moved here from #5107 so this PR works on its own.Runtime JavaScript keeps its
#mf/*imports so the consumer's conditions choose the file. Published declarations contain no#mf/*imports and point at the default files, so consumers onmoduleResolution: node10still get real types.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;
9fb0f2fc7is the rewritten tip.worker-remote-entry.spec.tsloads an ESM remote entry through the worker loader.Tests cover Node resolution, runtime behavior, and Webpack and Rspack graphs.
CI at
9fb0f2fc7passed 20 checks, cancelled 4, and skipped 13.The 4 cancelled checks are
checkout-installandnode20-compatin Build Affected Packages,lint-depsin Lint Dependencies, andpublish-previewin pkg.pr.new Preview. Those three workflows 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 run of each workflow passed on the same commit. The cancelled runs were not rerun.12 skipped checks are the jobs of the cancelled Build Affected Packages run, which wait on
checkout-install.e2e-treeshakewas skipped in the second run becausetools/scripts/ci-is-affected.mjsdid not select it.No compiler in this stack passes the conditions, so only the package tests exercise the selected files.
Deviations from the RFC
None noted.
Overlaps with open PRs
File overlaps with 10 other open PRs
packages/runtime-core/src/remote/index.ts. This PR does not include that change.packages/runtime-core/src/shared/disabled.ts. This PR does not include that change.packages/runtime-core/src/remote/index.ts. This PR does not include that change.packages/runtime-core/src/core.ts,packages/runtime-core/src/remote/disabled.ts,packages/runtime-core/src/remote/index.ts,packages/webpack-bundler-runtime/src/index.ts,packages/webpack-bundler-runtime/src/types.ts, andpackages/webpack-bundler-runtime/tsconfig.lib.json. This PR does not include those changes.packages/runtime-core/src/core.ts,packages/runtime-core/src/remote/index.ts,packages/webpack-bundler-runtime/src/index.ts,packages/webpack-bundler-runtime/src/types.ts, andpackages/webpack-bundler-runtime/tsconfig.lib.json. This PR does not include those changes.packages/runtime-core/src/remote/index.tsandpackages/runtime-core/src/shared/disabled.ts. This PR does not include those changes.packages/runtime-core/src/core.ts,packages/runtime-core/src/index.ts, andpackages/runtime-core/src/remote/index.ts. This PR does not include those changes.packages/runtime-core/src/core.ts,packages/runtime-core/src/remote/disabled.ts,packages/runtime-core/src/remote/index.ts,packages/webpack-bundler-runtime/src/index.ts,packages/webpack-bundler-runtime/src/types.ts, andpackages/webpack-bundler-runtime/tsconfig.lib.json. This PR does not include those changes.packages/runtime-core/src/remote/disabled.ts. This PR does not include that change.packages/runtime-core/src/core.ts. This PR does not include that change.