Skip to content

feat(managers): plan the runtime composition and resolve one runtime family - #5134

Open
ScriptedAlchemy wants to merge 18 commits into
rfc5128/03-node-esbuild-runtimefrom
rfc5128/04-managers-composition
Open

ScriptedAlchemy wants to merge 18 commits into
rfc5128/03-node-esbuild-runtimefrom
rfc5128/04-managers-composition

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Part of RFC #5128 (alternate proposal to #5036).
Stack: 4 of 7. Base: #5139 (rfc5128/03-node-esbuild-runtime). Next: #5140.
Landing order: #5135 → #5137 → #5139 → #5134 → #5140 → #5141 → #5142.
Companions on main: #5143 (disabled remote loadEntry), #5144 (enhanced duplicate serializer keys). #5126 (@rspack/core 2) is on main. PR 6 and 7 include it.

What changes

No build changes behavior in this PR. @module-federation/managers gains the pure build-side functions that decide how a federation build composes its runtime. Enhanced and rspack call them behind experiments.composedRuntime in #5140 and #5141, so both bundlers share one planner.

  • planComposition turns the plugin participants into the handlers and adapters a build needs.
  • resolveRuntimeFamily and selectMode find the installed runtime packages. They pick composed mode only when every needed subpath is exported and nothing externalizes or aliases the runtime.
  • resolveImports and renderComposition produce the generated bootstrap text.
  • checkFederationGraph reports missing adapters and family mismatches.

Verification

  • pnpm --filter @module-federation/managers test covers each function with synthetic package fixtures and a real older runtime-tools from the pnpm store. The suite passes 103/103.
  • An older runtime, an externalized runtime, and a user alias each select legacy.
  • Typecheck, lint, and prettier pass on packages/managers.
  • Independent verification passed at 1d75f2f40 (gates 95/95, red checks and mutations, built-dist bootstraps evaluate with the planned keys, runtime-tools 2.9.1 selects legacy, audit). Five follow-ups (byLayer, the contextInfo stub, a callback default parameter, the userRequest contract, and test types) each landed red-first and passed a delta review at 0568c389e. The patch is unchanged through 0576af69c and the live head a3a65b4be.
  • CI passes at a3a65b4be with 19 checks. e2e-metro-ios failed once in teardown after its Maestro flow passed. The serve process exited on SIGTERM and the harness counted that exit as a failure. The rerun passed.
  • Nothing calls these functions in this PR, so no bundler output was tested here. feat(enhanced): compose the runtime bootstrap behind experiments.composedRuntime #5140 and feat(rspack): redirect the native bundler runtime to a composed entry #5141 test them through real builds.

Deviations from the RFC

  • The rendered bootstrap ends with export default federation;, which the RFC examples omit. The rspack alias target and the enhanced entry need the federation object as the default export.

Overlaps with open PRs

This PR carries none of the spun-out main fixes and no code from other open PRs. The PRs below change files this PR also changes. This PR does not include their changes.

@changeset-bot

changeset-bot Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a3a65b4

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/managers Minor
@module-federation/dts-plugin Minor
@module-federation/enhanced Minor
@module-federation/manifest Minor
@module-federation/rspack Minor
@module-federation/cli Minor
@module-federation/metro 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/metro-plugin-rnc-cli Minor
@module-federation/metro-plugin-rnef Minor
@module-federation/metro-plugin-rock 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
create-module-federation Minor
@module-federation/error-codes Minor
@module-federation/retry-plugin Minor
@module-federation/runtime-core Minor
@module-federation/runtime-tools 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/inject-external-runtime-core-plugin 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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-25T13:30:20.655045Z 95cc87e PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

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

Copy link
Copy Markdown

Open in StackBlitz

@module-federation/devtools

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

@module-federation/cli

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

create-module-federation

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

@module-federation/dts-plugin

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

@module-federation/enhanced

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

@module-federation/error-codes

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

@module-federation/esbuild

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

@module-federation/managers

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

@module-federation/manifest

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

@module-federation/metro

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

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

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

@module-federation/metro-plugin-rnef

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

@module-federation/metro-plugin-rock

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

@module-federation/modern-js

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

@module-federation/modern-js-v3

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

@module-federation/native-federation-tests

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

@module-federation/native-federation-typescript

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

@module-federation/nextjs-mf

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

@module-federation/node

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

@module-federation/observability-plugin

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

@module-federation/playground

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

@module-federation/retry-plugin

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

@module-federation/rsbuild-plugin

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

@module-federation/rspack

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

@module-federation/rspress-plugin

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

@module-federation/rstest

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

@module-federation/runtime

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

@module-federation/runtime-core

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

@module-federation/runtime-tools

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

@module-federation/sdk

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

@module-federation/storybook-addon

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

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

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

@module-federation/treeshake-frontend

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

@module-federation/treeshake-server

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

@module-federation/typescript

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

@module-federation/utilities

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

@module-federation/webpack-bundler-runtime

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

@module-federation/bridge-react

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

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

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

@module-federation/bridge-shared

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

@module-federation/bridge-vue3

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

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

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

commit: a3a65b4

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Report

17 package(s) changed, 26 unchanged.

Package dist + ESM entry

Package Total dist (raw) Delta ESM gzip Delta
@module-federation/bridge-react 281.8 kB -30043 B (-9.4%) 1.5 kB no change
@module-federation/bridge-vue3 194.4 kB +2.7 kB (+1.4%) 27.9 kB +542 B (+1.9%)
@module-federation/dts-plugin 337.7 kB +2.0 kB (+0.6%) 4.7 kB no change
@module-federation/esbuild 255.1 kB +12 B (+0.0%) 67 B no change
@module-federation/managers 124.2 kB +53.4 kB (+75.5%) 366 B +122 B (+50.0%)
@module-federation/node 199.0 kB +622 B (+0.3%) 217 B no change
@module-federation/playground 16.01 MB -64886 B (-0.4%) 42.5 kB -3392 B (-7.2%)
@module-federation/runtime 23.5 kB +3.1 kB (+15.4%) 583 B -141 B (-19.5%)
@module-federation/runtime-core 326.4 kB +15.9 kB (+5.1%) 802 B +232 B (+40.7%)
@module-federation/runtime-tools 7.7 kB -65 B (-0.8%) 142 B no change
@module-federation/sdk 141.3 kB +12.4 kB (+9.6%) 784 B -1 B (-0.1%)
@module-federation/webpack-bundler-runtime 111.2 kB +43.1 kB (+63.3%) 614 B +83 B (+15.6%)

Bundle targets

Package Web bundle (gzip) Delta Node bundle (gzip) Delta
@module-federation/bridge-react 12.6 kB -960 B (-6.9%) 12.5 kB -1967 B (-13.4%)
@module-federation/bridge-vue3 20.6 kB +535 B (+2.6%) 21.5 kB +1.3 kB (+6.5%)
@module-federation/cli 2.3 kB -10 B (-0.4%) 2.4 kB -32 B (-1.3%)
@module-federation/core 1.0 kB -2 B (-0.2%) 1.0 kB -34 B (-3.1%)
@module-federation/devtools 30.3 kB no change 30.3 kB -25 B (-0.1%)
@module-federation/enhanced 2.7 kB +1 B (+0.0%) 2.8 kB -44 B (-1.5%)
@module-federation/managers 4.8 kB +2.4 kB (+100.0%) 4.8 kB +2.4 kB (+100.0%)
@module-federation/metro-plugin-rnc-cli 416 B +2 B (+0.5%) 435 B -26 B (-5.6%)
@module-federation/node 9.2 kB +32 B (+0.3%) 9.2 kB no change
@module-federation/playground 38.3 kB -3399 B (-8.0%) 38.3 kB -3399 B (-8.0%)
@module-federation/runtime 754 B +57 B (+8.2%) 754 B +57 B (+8.2%)
@module-federation/runtime-core 16.5 kB +393 B (+2.4%) 16.2 kB +366 B (+2.3%)
@module-federation/sdk 4.4 kB no change 5.9 kB +4 B (+0.1%)
@module-federation/webpack-bundler-runtime 4.2 kB +59 B (+1.4%) 4.2 kB +59 B (+1.4%)

Tree-shakable entrypoints

Package Export Entry gzip Delta Web bundle (gzip) Delta Node bundle (gzip) Delta Gap (node-web) Delta
@module-federation/runtime ./bundler 184 B no change 754 B +57 B (+8.2%) 754 B +57 B (+8.2%) 0 B 0 B
@module-federation/webpack-bundler-runtime ./bundler 151 B no change 4.2 kB +59 B (+1.4%) 4.2 kB +59 B (+1.4%) 0 B 0 B

Consumer scenarios

Scenario Web output (gzip) Delta Node output (gzip) Delta Gap (node-web) Delta
Enhanced remoteEntry 22.5 kB +198 B (+0.9%) 25.0 kB +1.1 kB (+4.8%) +2.5 kB +975 B

Total dist (raw): 23.44 MB (+40.5 kB (+0.2%))
Total ESM gzip: 109.2 kB (-2555 B (-2.2%))
Total web bundle (gzip): 252.6 kB (-815 B (-0.3%))
Total node bundle (gzip): 254.6 kB (-1225 B (-0.5%))
Tracked ./bundler entry gzip: 563 B (no change)
Tracked ./bundler web bundle (gzip): 5.0 kB (+116 B (+2.3%))
Tracked ./bundler node bundle (gzip): 5.0 kB (+116 B (+2.3%))

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

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: 95cc87ed64

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

'@module-federation/managers': minor
---

Add pure helpers that plan a composed federation runtime: `planComposition`, `resolveRuntimeFamily`, `selectMode`, `resolveImports`, `renderComposition`, and `checkFederationGraph`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove nonexistent helpers from the release note

When this changeset is consumed during a release, the generated changelog will advertise five APIs that users cannot import: a repository-wide search finds no implementations of resolveRuntimeFamily, selectMode, resolveImports, renderComposition, or checkFederationGraph, and packages/managers/src/index.ts exports only planComposition and ADAPTERS from this change. Either include and export those helpers or limit the release note to the API actually added.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Deploying with ☁️ Zephyr Cloud

The latest preview deployments for this pull request.

Status Name Latest Commit Version URL Updated (UTC)
✅ Deployment successful!
View deployment
website-new bf6f74b Version ↗ 25 Sept 2026, 14:00

Affected deployment targets

Application Type Target
website-new Environment latest ↗
website-new Tag latest ↗
website-new Tag web_rfc5128-04-managers-composition_nestor_lopez ↗

@ScriptedAlchemy
ScriptedAlchemy changed the base branch from main to rfc5128/03-node-esbuild-runtime September 25, 2026 13:58

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