build: Make pnpm build-profile emit usable rspack stats - #124296
Merged
Merged
Conversation
ryan953
marked this pull request as draft
September 14, 2026 16:53
`rspack --json` takes its stats options from the config, and the CLI has no flag to override them. Under `--mode production` the default preset drops to errors and warnings, so the file carried no assets, chunks, or entrypoints. Without that flag the default preset dumps every module with its source and the file grows past 300MB, which no analyzer will open. RSPACK_STATS gates a trimmed stats object on both configs, so build-profile now writes a ~3MB file holding the asset, chunk, and entrypoint data. Claude-Session: https://claude.ai/code/session_01Jp2jDjcwahdDYBBSmWFVXc
ryan953
marked this pull request as ready for review
September 14, 2026 22:03
scttcper
reviewed
Sep 15, 2026
scttcper
left a comment
Member
There was a problem hiding this comment.
Review by Astra. The env gate and direct JSON file output look reasonable. Two suggestions below: retain module detail if this is intended for bundle analyzers, and clarify the CLI defaults in the comment and PR description.
Co-authored-by: Scott Cooper <scttcper@gmail.com>
Co-authored-by: Scott Cooper <scttcper@gmail.com>
scttcper
approved these changes
Sep 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pnpm build-profiledid not produce a file anyone could analyze. The old script passed--profile, which rspack no longer accepts, and fixing the flag alone was not enough.rspack --jsonwrites whatever the configuredstatsoptions describe, and the CLI gives you no flag to override them.rspack.config.tsset nostats, so the CLI filled in its own default — theerrors-warningspreset, which it applies wheneverstatsis unspecified, independently of mode — and the JSON came out with no assets, chunks, or entrypoints in it at all. Settingstatswithout trimming it lands at the other extreme: module records carry their source text, which grew the output past 300MB.RSPACK_STATS=1now gates a trimmedstatsobject applied to both the app and service-worker configs. The env gate keeps normal builds and the dev server untouched, which seemed better than adding a second root-level config file just for profiling. The script also pinsNODE_ENV=productionand--mode productionso the profile matchesbuild-production, and it writes through--json=stats.rspack.jsoninstead of a shell redirect so CLI logging cannot end up inside the JSON.The gated block keeps the bundle shape: assets, chunks, chunk groups, entrypoints, and chunk parent/child/sibling relations, so the graph stays walkable. On the app compiler that is 5303 assets, 1684 chunks, the
app,gsAdminandsentryentrypoints, and 9 named chunk groups. Module records are included withsource: false, so module identity and nesting survive while the source text that pushed the file past 300MB stays out.The output file is gitignored.
https://claude.ai/code/session_01Jp2jDjcwahdDYBBSmWFVXc