Skip to content

perf(react): scope React DOM prebundles by environment - #532

Merged
cpojer merged 1 commit into
voidzero-dev:mainfrom
yangshun:perf/react-prebundle-scope
Oct 21, 2026
Merged

cpojer merged 1 commit into
voidzero-dev:mainfrom
yangshun:perf/react-prebundle-scope

Conversation

@yangshun

Copy link
Copy Markdown
Contributor

React Pages currently pre-includes both React DOM entry points in browser and Worker dependency optimization. Include react-dom/client in the browser and react-dom/server in the Worker, with regression coverage for those scopes and the existing SSR includes.

An installed-package comparison on a two-page React app reduced generated prebundle JavaScript by 1,580,422 bytes (source maps and metadata excluded):

Environment Before After
Client 1,660,390 B 992,097 B
Worker 1,669,081 B 756,952 B
SSR 2,705,925 B 2,705,925 B

The 80-sample benchmark used 20 randomized baseline/branch pairs for each cold/warm cache state, with fresh dev processes and browser contexts. Every sample passed hydration, interaction, and client-navigation checks. Browser transfer was effectively unchanged, and neither cold nor warm process-to-hydration time showed a statistically significant improvement (adjusted p = 0.751 and 0.800). This supports a smaller generated cache; it does not establish a startup speedup. Timings came from a small React fixture with background host activity.

Validation:

  • Focused React plugin tests: 4 passed.
  • vp run test --base origin/main: 10,750 passed, 31 skipped.
  • vp run check: all 33 tasks passed.
  • Formatting and lint passed for both changed files.
  • vp test run --pool=forks --maxWorkers=4: 14,048 passed, 31 skipped.

Keep react-dom/server out of the browser prebundle and react-dom/client out of the Worker prebundle. Preserve the existing SSR prebundle list; disabling the unused Cloudflare SSR optimizer is covered by perf/skip-ssr-prebundle.

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woah, nice!

@cpojer
cpojer merged commit 6c1a67c into voidzero-dev:main Oct 21, 2026
2 checks passed
@yangshun
yangshun deleted the perf/react-prebundle-scope branch October 21, 2026 12:40
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.

2 participants