perf: shrink classic production browser output - #117
Conversation
Enable production-only Rspack output size optimizations for classic mode: mangle export names, drop exports nothing imports across the whole graph, and name async chunks by id and content hash. Classic mode resolves route modules through the browser manifest by chunk, so export names are not part of its runtime contract. RSC mode is unchanged and keeps every export name because Flight resolves client references by name. Development builds are unchanged. Revives the classic-mode half of #85, which was closed pending the React Router 8 work. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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. |
commit: |
Benchmark results
|
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
Revives the classic-mode half of #85, which was closed pending the React Router 8 work. Classic production builds now set:
optimization.mangleExports: 'size'optimization.usedExports: 'global'output.chunkFilename: 'static/js/async/[id]-[contenthash:16].js'Classic mode resolves route modules through the browser manifest by chunk, so export names are not part of its runtime contract. RSC mode is untouched and keeps
mangleExports: false/usedExports: false, because Flight resolves client references by export name. Development builds are unchanged.Users who want readable export names in a classic production build can set the two optimization flags back in the function form of
tools.rspack, which runs after plugin defaults are merged.Measured
Gzipped client JS, built from this branch versus 0.6.1:
Smaller than #85's synthetic numbers, which is expected: the synthetic fixtures had far more routes and re-exports to mangle. The epic-stack example's node build fails on
mainfor an unrelated reason, so only its emitted client output was measured.Verification
pnpm typecheck,pnpm exec rstest run(all files pass)tests/index.test.tscases: classic build enables the flags and chunk filename, classic dev leaves them undefined, RSC build still disables mangling🤖 Generated with Claude Code