Skip to content

perf: shrink classic production browser output - #117

Merged
ScriptedAlchemy merged 1 commit into
mainfrom
perf/classic-production-output-size
Sep 4, 2026
Merged

perf: shrink classic production browser output#117
ScriptedAlchemy merged 1 commit into
mainfrom
perf/classic-production-output-size

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Collaborator

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:

Example Before After Delta
default-template 111.0 kB 110.4 kB -0.5%
epic-stack (client output) 336.1 kB 332.1 kB -1.2%

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 main for an unrelated reason, so only its emitted client output was measured.

Verification

  • pnpm typecheck, pnpm exec rstest run (all files pass)
  • New tests/index.test.ts cases: classic build enables the flags and chunk filename, classic dev leaves them undefined, RSC build still disables mangling

🤖 Generated with Claude Code

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>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-03T23:35:04.933014Z 526634d PR opened
ℹ️ 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.

@pkg-pr-new

pkg-pr-new Bot commented Sep 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/rsbuild-plugin-react-router@526634d

commit: 526634d

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Benchmark results

Case Base Head Delta
build-256-ssr 1274.8 ms 1248.9 ms -2.0%
dev-48-ssr 584.3 ms 583.5 ms -0.1%

@codspeed-hq

codspeed-hq Bot commented Sep 3, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 1 untouched benchmark
⏩ 2 skipped benchmarks1


Comparing perf/classic-production-output-size (526634d) with main (cabf4b9)2

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (0963271) during the generation of this report, so cabf4b9 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@ScriptedAlchemy
ScriptedAlchemy merged commit b5b0e7b into main Sep 4, 2026
9 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the perf/classic-production-output-size branch September 4, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant