perf(manifest): collect Webpack stats from the compilation graph - #5080
ScriptedAlchemy wants to merge 4 commits into
Conversation
🦋 Changeset detectedLatest commit: b99a1c3 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. |
@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 Report11 package(s) changed, 32 unchanged. Package dist + ESM entry
Bundle targets
Consumer scenarios
Total dist (raw): 23.42 MB (+14.1 kB (+0.1%)) Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 07527d3fd3
ℹ️ 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".
| const version = | ||
| 'version' in data | ||
| ? JSON.parse(data.version) | ||
| : (normalized?.version ?? sharedMap[key]?.version); | ||
| if (!name || !version) continue; |
There was a problem hiding this comment.
Preserve consume-only shares with exact versions
When a shared dependency is configured with import: false, is absent from the local installation, and has an exact requiredVersion, normalized.version is undefined and consume code-generation data contains no version, so this branch skips the dependency entirely. The legacy reader recovered the exact version from the consume identifier; because graph collection is now the default, the generated stats and manifest unexpectedly lose this valid shared entry unless useLegacyStats is enabled.
Useful? React with 👍 / 👎.
|
One thing from a read of this diff, not reproduced. |
Deploying with ☁️ Zephyr CloudThe latest preview deployments for this pull request.
Affected deployment targets
|
Description
Collect Webpack federation manifest data directly from the compilation graph instead of serializing Webpack stats and parsing module identifiers.
This is the base PR for layer support, which is stacked on this branch. This PR adds no layer API, layer metadata, runtime protocol, preview dependency, or lockfile change.
What changes
Read exposes, shared modules, remotes, and assets from module/chunk/code-generation data, reusing the existing normalized managers.
Use this path by default when the required Webpack metadata is available. Keep the previous reader when it is unavailable.
Add an explicit rollback option:
Omitting the option, or setting it to
false, uses graph collection where supported. Native Rspack stats and their JavaScript post-processing are unchanged. The option is also documented in the English and Chinese manifest configuration guides.Keep the rollback reader’s pre-PR handling of unnamed chunk groups. A real Webpack fixture with
import("./other.js"),other.jsimporting an exposed component, and split chunks confirms that rollback excludes the unrelatedother_js.jsfrom expose assets. The graph collector explicitly retains its wider group collection.Correct direct expose-to-shared relationships: an expose importing a shared module now records that share in
requires, and the share records the expose inusedIn. These existing fields were empty in the old reader for the tested enhanced-sharing case. This is an intentional output correction, not a claim of byte-for-byte equivalence.Review order
packages/manifest/src/collectGraph.ts: structured collection, actual compiler-selected remote aliases, and asset association.StatsManager.ts: select the collector or old reader, then use common finalization. Removes synchronous Promise wrappers; preserves asset emission andadditionalDataorder.Graph.spec.ts: real Webpack builds compare both emitted JSON artifacts with default, explicit graph, and rollback modes; includes filesystem-cache restoration, shared prefixes, and overlapping/unused remotes.pnpm run generate:schema.Related Issue
Related performance reports: #3713 and #4286. This does not claim to reproduce or fix those applications' complete build times. The layers follow-up is #5039.
Validation
Latest follow-up: the foundation manifest suite passes 13/13, including the regression above against both emitted JSON files; manifest build, package lint, changed-file formatting and normal commit hooks pass. The exact pre-PR asset helper at
ee32a0d1returns onlyexposed.jsfor this fixture. Full local root formatting is blocked by an unrelated missing Next-app@tailwindcss/typographydependency; the exact-head hosted package, Node 20, and broad E2E jobs pass. No full application/native compiler rerun is claimed for this foundation check.Benchmark
Successful isolated CI run and raw artifacts: 100 exposes, 20 common imports per expose, one shared singleton, and synchronous/asynchronous JS/CSS. Webpack 5.104.1, Node 24.18.0, GitHub-hosted Ubuntu 24.04. Both modes use commit
07527d3and the same built packages, changing onlymanifest.useLegacyStats.Five alternating independent process pairs, one discarded warmup pair, and three real single-source HMR edits per process. Values are median [min–max] in milliseconds unless noted. Rebuild statistics summarize each process's median first.
Manifests and asset lists matched. Stats differed only by the documented
requires/usedIncorrection; no unexpected differences or warnings. Every measured edit rebuilt exactly one source module and emitted HMR updates. Each compilation calledStats.toJsononce with the previous reader and zero times with graph collection.Stats generation measures
generateStats, not just the inner graph function. Build time excludes process startup and watcher debounce; RSS includes setup and rebuilds. OS caches were not cleared. Process sampling found no competing compiler/test, but cannot exclude underlying hosted-machine contention. These are synthetic-fixture results, not a universal speedup or the original report's full application.Additional local evidence, measured separately on Node 22.23.2: a 2,000-module fixture with one remote and no exposes/shares improved median cold build from 1,581 to 1,448 ms and rebuilds from 289 to 201 ms, with exact JSON equality. Earlier local expose runs overlapped unrelated builds and remain excluded.
Types of changes
Checklist
Focused checks passed as listed above; the complete workspace suite was not run.