Skip to content

fix(node,esbuild): load through the instance platform instead of federation.runtime - #5139

Open
ScriptedAlchemy wants to merge 11 commits into
rfc5128/02-bundler-runtime-composefrom
rfc5128/03-node-esbuild-runtime
Open

ScriptedAlchemy wants to merge 11 commits into
rfc5128/02-bundler-runtime-composefrom
rfc5128/03-node-esbuild-runtime

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Part of RFC #5128 (alternate proposal to #5036).
Stack: 3 of 7. Base: #5137 (rfc5128/02-bundler-runtime-compose). Next: #5134.
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

Node hosts and esbuild containers now run on the composed bundler runtime from #5137, whose federation.runtime has only init. On the legacy runtime they behave as before.

The node runtime plugin and the chunk loader it emits call instance.platform.loadScriptNode when the instance's platform has one. Otherwise they fall back to federation.runtime.loadScriptNode, so an older runtime still works. If neither exists, the loader rejects through its callback with an error that names the missing Node platform, instead of throwing a TypeError. The esbuild container template calls bundlerRuntime.init instead of runtime.init.

The esbuild package had no test suite. This PR adds a small jest setup for it so the container template has a behavioral test.

Verification

  • In packages/esbuild, the container template initializes with createFederation from the composed bundler runtime and with the legacy root. The composed case failed with runtime.init is not a function before this change, when the refactor(webpack-bundler-runtime): compose the bundler runtime from adapters #5137 shim had no init.
  • In packages/node, a runtime-plugin test with a custom platform whose loadScriptNode records its calls proves the platform loader is used and federation.runtime is not. A legacy-shaped federation object still loads through the fallback.
  • In packages/node, the same two cases run against the code generateLoadScript emits.
  • In packages/node, with no loader on the platform or on federation.runtime, the plugin and the emitted loader both pass a named No Node script loader error to the callback. Both tests failed before the change.
  • pnpm test passes in node (59/59) and esbuild (2/2). Lint and prettier pass.
  • An end-to-end Node host with @module-federation/node/runtimePlugin passes in the stack proof harness (webpack, legacy mode).
  • Independent verification passed at 88f4713e1. The full review ran at 67084469e (gates, red checks, proof harness 32/32, audit). The instance?.platform guard and the named loader error each passed a delta review. The live head 302500c86 has the same patch over its parent.
  • CI passes at 302500c86 with 14 checks. e2e-runtime, e2e-manifest, e2e-treeshake, and e2e-metro were skipped because the affected-suite selector did not pick them.
  • No end-to-end run covers a composed Node host in this PR. The composed async-node checks run in the proof harness from feat(enhanced): compose the runtime bootstrap behind experiments.composedRuntime #5140 onward.

Deviations from the RFC

None.

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: 302500c

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/node Patch
@module-federation/esbuild Patch
@module-federation/modern-js-v3 Patch
@module-federation/modern-js Patch
@module-federation/nextjs-mf Patch
@module-federation/rsbuild-plugin Patch
@module-federation/rstest Patch
node-dynamic-remote-new-version Patch
node-dynamic-remote Patch
shared-tree-shaking-with-server-host Patch
shared-tree-shaking-with-server-provider Patch
@module-federation/playground Patch
@module-federation/rspress-plugin Patch
remote5 Patch
remote6 Patch
website-new Patch
@module-federation/devtools Patch
@module-federation/cli Patch
create-module-federation Patch
@module-federation/dts-plugin Patch
@module-federation/enhanced Patch
@module-federation/error-codes Patch
@module-federation/managers Patch
@module-federation/manifest Patch
@module-federation/metro Patch
@module-federation/metro-plugin-rnc-cli Patch
@module-federation/metro-plugin-rnef Patch
@module-federation/metro-plugin-rock Patch
@module-federation/retry-plugin Patch
@module-federation/rspack Patch
@module-federation/runtime-core Patch
@module-federation/runtime-tools Patch
@module-federation/runtime Patch
@module-federation/sdk Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/treeshake-frontend Patch
@module-federation/treeshake-server Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/bridge-react Patch
@module-federation/bridge-shared Patch
@module-federation/bridge-vue3 Patch
@module-federation/inject-external-runtime-core-plugin Patch
@module-federation/storybook-addon Patch
shared-tree-shaking-no-server-host Patch
shared-tree-shaking-no-server-provider 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:52:55.571861Z 6708446 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@302500c

@module-federation/cli

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

create-module-federation

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

@module-federation/dts-plugin

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

@module-federation/enhanced

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

@module-federation/error-codes

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

@module-federation/esbuild

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

@module-federation/managers

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

@module-federation/manifest

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

@module-federation/metro

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

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

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

@module-federation/metro-plugin-rnef

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

@module-federation/metro-plugin-rock

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

@module-federation/modern-js

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

@module-federation/modern-js-v3

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

@module-federation/native-federation-tests

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

@module-federation/native-federation-typescript

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

@module-federation/nextjs-mf

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

@module-federation/node

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

@module-federation/observability-plugin

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

@module-federation/playground

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

@module-federation/retry-plugin

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

@module-federation/rsbuild-plugin

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

@module-federation/rspack

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

@module-federation/rspress-plugin

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

@module-federation/rstest

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

@module-federation/runtime

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

@module-federation/runtime-core

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

@module-federation/runtime-tools

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

@module-federation/sdk

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

@module-federation/storybook-addon

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

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

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

@module-federation/treeshake-frontend

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

@module-federation/treeshake-server

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

@module-federation/typescript

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

@module-federation/utilities

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

@module-federation/webpack-bundler-runtime

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

@module-federation/bridge-react

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

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

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

@module-federation/bridge-shared

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

@module-federation/bridge-vue3

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

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

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

commit: 302500c

…TypeError

The composed runtime object no longer carries loadScriptNode. When neither
the instance platform nor federation.runtime can load a Node script, the
plugin and the emitted chunk loader now reject with an error that names
the missing platform capability, routed to the loader callback.

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