Repository navigation
fix(enhanced): make the generated runtime entry deterministic and valid - #5123
Conversation
🦋 Changeset detectedLatest commit: dc6b00b 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5987217d21
ℹ️ 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/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: |
Bundle Size Report6 package(s) changed, 37 unchanged. Package dist + ESM entry
Bundle targets
Consumer scenarios
Total dist (raw): 23.41 MB (+1.2 kB (+0.0%)) Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as |
…erals, and a stable name Three assertions on FederationRuntimePlugin.getTemplate and the fallback container name. Each fails on main: a relative runtimePlugins entry resolves against process.cwd() instead of compiler.context, a path that contains a quote makes webpack's parser reject the entry, and the fallback name changes with the clock between two builds.
The fallback container name was container_${Date.now()}. It fed both the
runtime init options and the temp entry hash, so two identical builds
without output.uniqueName produced different contenthashes and a new
node_modules/.federation entry each build. The clock was there to keep
runtime instances apart when two builds share a page; a short hash of
compiler.context keeps them apart just as well and is the same on every
build of the same project.
getTemplate pasted the bundler runtime path and every runtimePlugins path
inside single quotes, so a path that contains a quote produced an entry
webpack's parser rejects. Emit them with JSON.stringify like every other
webpack template.
Relative runtimePlugins entries resolved against process.cwd() although the
compiler is in scope. Resolve them against compiler.context like every
other relative path webpack accepts.
…ive runtime plugins loading The fallback name now hashes compiler.options.name with compiler.context, so two compilers of one config that share a context get different names. compiler.name is not used because webpack only sets it inside a MultiCompiler. A build that uses the fallback gets a warning that asks for output.uniqueName or a plugin name. A relative runtimePlugins path that does not exist under compiler.context but does exist under process.cwd() still loads from cwd, with a warning that asks to update the path. This keeps context: __dirname with a cwd-relative entry working when the build runs from another directory. The unit test parses nothing: it asserts the JSON.stringify form of each import specifier instead of calling webpack's private JavascriptParser._parse.
The warning fired in 21 sharing config cases and 2 container cases, every standalone ContainerReferencePlugin or SharePlugin build in the suite, so it marks a normal setup rather than a misconfiguration. webpack itself does not warn on an empty uniqueName. The stable fallback name and the cwd-fallback warning for runtimePlugins stay.
d063319 to
dc6b00b
Compare
Description
FederationRuntimePluginuses a timestamp for unnamed containers, inserts paths into unescaped string literals, and resolves relative runtime plugins from the working directory. This changes generated entries between builds and breaks quoted paths or configs run from another directory.Use a hash of compiler name and context for the fallback name, escape import specifiers with
JSON.stringify, and resolve plugins from the compiler context. Preserve the working-directory fallback with a warning. The name is stable within a checkout; it still depends on the absolute context.Validation previously recorded: 19 focused tests, the fallback config case, a build under a quoted path, and enhanced tests pass. Windows quoted paths and #4954's package-name integration were not tested. Reported CI passes; Metro and tree-shaking E2E are skipped.
Related Issue
Related PR: #4954 changes the same plugin-resolution code. Reconcile both paths using
compiler.contextwhen merging.Types of changes
Checklist