Skip to content

perf(nextjs-mf): derive federated stats from manifest#4909

Merged
ScriptedAlchemy merged 5 commits into
mainfrom
codex/optimize-federated-stats
Jul 17, 2026
Merged

perf(nextjs-mf): derive federated stats from manifest#4909
ScriptedAlchemy merged 5 commits into
mainfrom
codex/optimize-federated-stats

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Jul 17, 2026

Copy link
Copy Markdown
Member

Description

Use mf-manifest.json as the primary source of expose assets for Next.js flushChunks, avoiding the second full Webpack stats traversal that made federated-stats.json expensive on large builds.

Rolling upgrades remain bidirectionally compatible: new hosts fall back to federated-stats.json for old or partially analyzed remotes, while new remotes still emit both historical stats filenames with the expose fields consumed by old hosts. Custom manifest filenames, browser and SSR public paths, nested/scoped aliases, CSS assets, and missing exposes are covered.

Because this resolves #4706 under the default configuration, the unreleased skipFederatedStats option and changeset from #4732 are removed instead of retaining a public performance flag. manifest: false and disableAssetsAnalyze still select complete legacy stats generation for configurations that do not provide analyzed manifest assets.

The local Next fixture removed the measured 286.60 ms stats.toJson correlation call while still emitting both compatibility assets. Final production E2E completed 19/19 tasks and 28 browser tests with no failures. Focused suites passed 52 node tests, 26 nextjs-mf tests, and 69 SDK tests with one existing skip; affected builds passed 18/18 tasks. The repo-wide Prettier gate remains blocked only by pre-existing generated packages/playground/src/generated/bridgeRuntimeFiles.ts; all changed files pass formatting.

Related Issue

Closes #4706. Supersedes the unreleased performance opt-out from #4732.

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 Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9b9d9ac

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

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

Copy link
Copy Markdown

Open in StackBlitz

@module-federation/devtools

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

@module-federation/cli

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

create-module-federation

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

@module-federation/dts-plugin

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

@module-federation/enhanced

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

@module-federation/error-codes

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

@module-federation/esbuild

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

@module-federation/managers

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

@module-federation/manifest

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

@module-federation/metro

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

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

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

@module-federation/metro-plugin-rnef

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

@module-federation/metro-plugin-rock

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

@module-federation/modern-js

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

@module-federation/modern-js-v3

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

@module-federation/native-federation-tests

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

@module-federation/native-federation-typescript

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

@module-federation/nextjs-mf

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

@module-federation/node

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

@module-federation/observability-plugin

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

@module-federation/playground

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

@module-federation/retry-plugin

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

@module-federation/rsbuild-plugin

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

@module-federation/rspack

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

@module-federation/rspress-plugin

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

@module-federation/runtime

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

@module-federation/runtime-core

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

@module-federation/runtime-tools

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

@module-federation/sdk

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

@module-federation/storybook-addon

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

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

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

@module-federation/treeshake-frontend

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

@module-federation/treeshake-server

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

@module-federation/typescript

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

@module-federation/utilities

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

@module-federation/webpack-bundler-runtime

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

@module-federation/bridge-react

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

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

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

@module-federation/bridge-shared

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

@module-federation/bridge-vue3

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

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

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

commit: 9b9d9ac

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

🚀 Preview Environment Ready!

Name Status URL
website-new ✅ Active https://nestor-lopez-30019-website-new-core-module-federa-ce08b3f... ↗

Details:

  • Latest Commit: 9b9d9ac
  • Updated at: 7/17/2026, 11:22:22 PM

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Report

12 package(s) changed, 30 unchanged.

Package dist + ESM entry

Package Total dist (raw) Delta ESM gzip Delta
@module-federation/bridge-vue3 179.6 kB +19 B (+0.0%) 26.0 kB +7 B (+0.0%)
@module-federation/nextjs-mf 163.3 kB +7.1 kB (+4.5%) 160 B no change
@module-federation/node 198.0 kB +4.8 kB (+2.5%) 217 B no change
@module-federation/playground 28.83 MB -714 B (-0.0%) 43.6 kB no change
@module-federation/runtime-tools 7.7 kB -65 B (-0.8%) 142 B no change
@module-federation/sdk 128.9 kB +183 B (+0.1%) 785 B no change
@module-federation/utilities 107.6 kB -34 B (-0.0%) 227 B no change

Bundle targets

Package Web bundle (gzip) Delta Node bundle (gzip) Delta
@module-federation/bridge-vue3 19.2 kB -1 B (-0.0%) 19.5 kB -1 B (-0.0%)
@module-federation/cli 2.3 kB -3 B (-0.1%) 2.4 kB -32 B (-1.3%)
@module-federation/core 1.0 kB -3 B (-0.3%) 1.0 kB -34 B (-3.1%)
@module-federation/devtools 30.3 kB -4 B (-0.0%) 30.3 kB -27 B (-0.1%)
@module-federation/enhanced 2.7 kB +2 B (+0.1%) 2.8 kB -44 B (-1.5%)
@module-federation/metro-plugin-rnc-cli 416 B no change 435 B -26 B (-5.6%)
@module-federation/nextjs-mf 5.1 kB +396 B (+8.1%) 5.1 kB +396 B (+8.1%)
@module-federation/node 9.2 kB no change 9.2 kB -28 B (-0.3%)
@module-federation/sdk 4.4 kB +3 B (+0.1%) 5.9 kB +2 B (+0.0%)

Consumer scenarios

Scenario Web output (gzip) Delta Node output (gzip) Delta Gap (node-web) Delta
Enhanced remoteEntry 21.4 kB -16 B (-0.1%) 23.1 kB -13 B (-0.1%) +1.7 kB +3 B

Total dist (raw): 35.79 MB (+11.3 kB (+0.0%))
Total ESM gzip: 104.9 kB (+7 B (+0.0%))
Total web bundle (gzip): 233.5 kB (+390 B (+0.2%))
Total node bundle (gzip): 236.1 kB (+206 B (+0.1%))
Tracked ./bundler entry gzip: 556 B (no change)
Tracked ./bundler web bundle (gzip): 4.8 kB (no change)
Tracked ./bundler node bundle (gzip): 4.8 kB (no change)

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.

Comment thread apps/website-new/docs/zh/integrations/framework/nextjs/index.mdx Outdated
@ScriptedAlchemy
ScriptedAlchemy requested a review from danpeen July 17, 2026 23:20
@ScriptedAlchemy
ScriptedAlchemy merged commit d901e2c into main Jul 17, 2026
25 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the codex/optimize-federated-stats branch July 17, 2026 23:38
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.

Avoid expensive webpack stats serialization for large Next.js MF builds

1 participant