Skip to content

feat(enhanced): coordinate runtime family selection - #5094

Open
ScriptedAlchemy wants to merge 17 commits into
rfc5036/01-runtime-family-resolverfrom
rfc5036/02-compiler-coordination
Open

ScriptedAlchemy wants to merge 17 commits into
rfc5036/01-runtime-family-resolverfrom
rfc5036/02-compiler-coordination

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

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: 2 of 7. Base: #5093 (rfc5036/01-runtime-family-resolver). Next: #5095.
Landing order: #5093 → #5094 → #5095 → #5096 → #5097 → #5098 → #5107.

What changes

Enhanced and Rspack now pick one runtime family and one capability profile per compiler, so plugin order no longer changes the build. An incomplete custom runtime family fails the build instead of falling back to the runtime packages installed next to the plugin. A federation plugin applied to a child compiler fails the build instead of being ignored. Default builds keep the compatibility defines with the same values as main.

Only top-level federation plugins join one per-compiler selection slot. afterResolvers finalizes the family and the capability profile, then applies one DefinePlugin with the combined FEDERATION_OPTIMIZE_*, FEDERATION_HAS_EXPOSES, and ENV_TARGET defines. Child compilers copy the parent's finalized selection. Each plugin still writes FEDERATION_BUILD_IDENTIFIER when it is applied, as on main.

In Enhanced, the bootstrap path comes from the finalized family before make writes the entry, and installed copies of the runtime plugin share one state object. The generated runtime entry imports the bundler runtime through @module-federation/runtime-tools/dist/federation-facade.js, which re-exports @module-federation/webpack-bundler-runtime. On main it imports the @module-federation/webpack-bundler-runtime/bundler entry directly. Rspack keeps its current bootstrap until native Rspack reports facade support, and it still rejects a second ModuleFederationPlugin in one compiler.

Package conditions stay off until the graph checks exist.

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; d077ea196 is the rewritten tip.

  • Tests compile a small entry with each bundler's plugin. They assert the define values the bundle sees and that a child compiler inherits the parent selection.

  • The Enhanced unit and tree-shaking config-case Rstest suites, the Rspack Jest suite, tsc for both packages, and Prettier pass.

  • CI at d077ea196 passed 17 checks. e2e-metro and e2e-treeshake were skipped because tools/scripts/ci-is-affected.mjs did not select them for this diff.

  • No build here sets module-federation:* conditions, and Rspack does not use the facade. e2e-treeshake has not run on this code. Its last run was at feat(managers): resolve runtime families atomically #5093's head.

Deviations from the RFC

None noted.

Overlaps with open PRs

File overlaps with 6 other open PRs

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@changeset-bot

changeset-bot Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d077ea1

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

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

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

@pkg-pr-new

pkg-pr-new Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@module-federation/devtools

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

@module-federation/cli

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

create-module-federation

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

@module-federation/dts-plugin

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

@module-federation/enhanced

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

@module-federation/error-codes

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

@module-federation/esbuild

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

@module-federation/managers

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

@module-federation/manifest

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

@module-federation/metro

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

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

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

@module-federation/metro-plugin-rnef

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

@module-federation/metro-plugin-rock

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rock@d077ea1

@module-federation/modern-js

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

@module-federation/modern-js-v3

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

@module-federation/native-federation-tests

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

@module-federation/native-federation-typescript

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

@module-federation/nextjs-mf

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

@module-federation/node

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

@module-federation/observability-plugin

pnpm add https://pkg.pr.new/@module-federation/observability-plugin@d077ea1

@module-federation/playground

pnpm add https://pkg.pr.new/@module-federation/playground@d077ea1

@module-federation/retry-plugin

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

@module-federation/rsbuild-plugin

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

@module-federation/rspack

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

@module-federation/rspress-plugin

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

@module-federation/rstest

pnpm add https://pkg.pr.new/@module-federation/rstest@d077ea1

@module-federation/runtime

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

@module-federation/runtime-core

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

@module-federation/runtime-tools

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

@module-federation/sdk

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

@module-federation/storybook-addon

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

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

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

@module-federation/treeshake-frontend

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

@module-federation/treeshake-server

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

@module-federation/typescript

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

@module-federation/utilities

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

@module-federation/webpack-bundler-runtime

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

@module-federation/bridge-react

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

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

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

@module-federation/bridge-shared

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

@module-federation/bridge-vue3

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

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

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

commit: d077ea1

@ScriptedAlchemy
ScriptedAlchemy force-pushed the rfc5036/01-runtime-family-resolver branch 2 times, most recently from 335ca42 to d52545d Compare September 18, 2026 15:33
@ScriptedAlchemy
ScriptedAlchemy force-pushed the rfc5036/02-compiler-coordination branch from 8939c8c to 8cb38c9 Compare September 18, 2026 15:36
Aggregate runtime requirements once after resolver setup.

Keep compatibility defines while custom implementations resolve as one family.

Add the default-only facade and retain the legacy Rspack bootstrap until native support is present.
@ScriptedAlchemy
ScriptedAlchemy force-pushed the rfc5036/02-compiler-coordination branch from 8cb38c9 to 5588bd3 Compare September 18, 2026 16:08
The selection slot change dropped the duplicate plugin check, so Rspack
accepted two ModuleFederationPlugin instances in one compiler. Restore the
check from main.

The spec now compiles a small entry through the real plugin. It asserts the
define values the bundle sees and that a child compiler inherits the parent
selection.
The local-provided-version case committed ten node_modules packages that the
config-case harness generates at test time. App.js does not import them.
Every setRuntimeAlias call uses the paths that prepareRuntime takes from
the finalized selection. Delete getRuntimeAlias, the usePreparedPaths flag,
and the custom implementation branch of resolveRuntimePaths that only they
reached. The unit tests now cover the live paths.
finalizeRuntimeSelection always returns a profile and an image, so the
early returns in Enhanced and Rspack never ran. Inline the one-line
copySelectionToChild wrapper. Remove runtimeCapabilityDefines, which only
the old Rspack spec used.
Compile a small entry through ModuleFederationPlugin and read the define
values from the bundle. Check that a child compiler inherits the parent
selection.
Main always set `@module-federation/runtime$` to the resolved runtime entry.
This branch had started keeping a user-provided string alias instead, which
changes default resolution. Restore the overwrite.
The no-remote case again configures remotes with disableRemote, as on main.
The resolver now lets a plugin's disable flag win over its own remotes.
Enhanced does not depend on @module-federation/runtime. Resolving it from
enhanced's own location threw MODULE_NOT_FOUND when the plugin module
loaded under a strict install. Resolve runtime and the bundler runtime
from the runtime-tools install, as main does.

This branch has not been deployed

No deployments
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.

1 participant