Skip to content

perf(manifest): use Rspack's native stats instead of serializing every module - #5305

Open
enekos wants to merge 4 commits into
module-federation:mainfrom
enekos:perf/rspack-native-manifest
Open

enekos wants to merge 4 commits into
module-federation:mainfrom
enekos:perf/rspack-native-manifest

Conversation

@enekos

@enekos enekos commented Nov 28, 2026 •

Copy link
Copy Markdown

Description

@module-federation/rspack builds mf-stats.json by calling compilation.getStats().toJson({ modules, reasons }) over every module, then keeps about a dozen of them. #5080 fixed this for Webpack only. Rspack already writes the same stats natively when manifest is set, and the JS plugin already has a branch that completes those native stats. The rspack plugin never switched it on, so apps that leave manifest unset went through toJson().

With the default manifest setting, Rspack 2.3.0 and later emit federation stats from the compiler graph. The plugin enables the native emitter when the public path supports manifest generation. Explicit manifest: false, older Rspack versions, and Webpack keep their existing defaults.

The JS plugin uses the container's configured library type and reads each expose's files from its own chunk group in load order. This keeps the remote loader, CSS cascade, and route-specific assets correct. It restores shared configuration and versions, and attributes each share to the public exposes that consume it, including multi-import exposes and layered aliases. A consumer-only build leaves the remote entry name empty.

When released compilers collapse aliases, merge ambiguous share scopes, or omit share versions, the plugin can still call the JS stats collector. Ordinary builds and unambiguous custom scopes avoid full module serialization. An uninferable version can report requiredVersion: null in place of "^undefined".

Asset collection also reads process.env.NODE_ENV once per asset list and reuses chunk-name lookups.

Validation

On Node 24, both affected packages built, type-checked, and linted. All 115 manifest and 32 Rspack tests passed. The manifest demo passed eight Cypress tests in development and eight in production. Workspace formatting passed. Testing was scoped to the affected packages and manifest demo.

The regression fixtures exercise the public plugin with manifest omitted. I checked the emitted metadata on released Rspack 2.3.0, 2.3.3, and 2.3.4. In Chrome on 2.3.3, the host loaded the global container with an ESM application output, and the component's style override won in both build modes. In development, loading the expose also left the unrelated route stylesheet out of the host.

I measured the final changes on released Rspack 2.3.3 with 10,000 leaf modules and 100 exposes. Each configuration had one initial build and six file-change rebuilds. Local median rebuild times were:

Share scope Previous default PR head Full module serializations at PR head
Default 191.5 ms 48.5 ms 0 of 7 builds
Custom team scope 195.5 ms 50 ms 0 of 7 builds

Related work

The original Rsbuild performance report is #3713. Rspack #16754 addresses alias emission in the compiler. This PR also handles the published compilers affected by that issue.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

@changeset-bot

changeset-bot Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ad798e5

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/manifest Patch
@module-federation/rspack Patch
@module-federation/enhanced Patch
@module-federation/modern-js-v3 Patch
@module-federation/modern-js Patch
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/rsbuild-plugin Patch
@module-federation/rspress-plugin Patch
@module-federation/rstest Patch
@module-federation/storybook-addon Patch
shared-tree-shaking-no-server-host Patch
shared-tree-shaking-no-server-provider Patch
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 Patch
@module-federation/cli Patch
create-module-federation Patch
@module-federation/dts-plugin Patch
@module-federation/error-codes Patch
@module-federation/managers 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/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/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

@enekos
enekos marked this pull request as ready for review November 28, 2026 17:30
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T17:35:50.362576Z 24916a4 Draft marked ready
ℹ️ 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.

@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: 24916a4a09

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

Comment thread packages/manifest/src/StatsManager.ts Resolved

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