fix(webviews): keep react-dom's server renderer out of the shared vendor chunk

Merged
TE
2mo ago
+114-105

Summary

feat-cmux-next's react-apps-check fails the diff viewer's eager-JS budget (1,612,988 bytes against 1,500,000), which blocks every web PR.

The cause is 8eef4842b70. It renders the markdown editor's read-only task checkbox with react-dom/server. The chunk rules put all of react-dom into the shared vendor chunk, so vendor.mjs grew from 271,798 to 459,433 bytes. Every viewer page loads that chunk on open.

  • webviews/vite.config.ts: react-dom's server renderer is no longer pinned to vendor, so it stays with its one importer, the markdown page.
  • scripts/check-webviews-diff-budget.mjs: the markdown page's budget goes from 1.2 MB to 1.4 MB. That page does evaluate the server renderer, and the reason is written next to the budget.
  • Resources/markdown-viewer/webviews-app: regenerated with build-webviews-app.sh.

Testing

node scripts/check-webviews-diff-budget.mjs is the regression check. It is red on base (before this PR) and green with this PR:

Eager JSBaseThis PRBudget
diff surface1,612,9881,425,3531,500,000
diff page1,610,0191,422,3841,500,000
markdown page1,354,7491,354,8971,200,000 to 1,400,000
editor page619,728432,093500,000

Also passing locally on bun 1.4.2:

  • build-webviews-app.sh --check
  • build-agent-pane-web.sh --check
  • build-web-bundles.sh, whose output matches the committed bundles byte for byte.

The webviews unit tests were not run locally; CI runs them.

Changelog

none

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Keeps react-dom's server renderer out of the shared vendor chunk. The markdown editor renders its read-only task checkbox with react-dom/server, and the chunk rules previously put the whole package in vendor, which every viewer page evaluates on open. That pushed the diff viewer over its 1.5 MB eager JS budget.

  • The server renderer now stays with its single importer, the markdown page.
  • The markdown page's budget rises to 1.4 MB, with the reason documented in scripts/check-webviews-diff-budget.mjs.
  • Regenerates the committed webviews app bundles on the merged feat-cmux-next base.

[!NOTE]
Low Risk
Bundling and CI budget changes only; no runtime auth, data, or API behavior beyond smaller eager loads for diff/editor pages.

Overview
Fixes diff and editor webview pages failing the 1.5 MB eager JS budget after the markdown editor started using react-dom/server to render read-only task checkboxes as static markup for ProseMirror decorations.

Vite chunking now returns null for react-dom/server paths so that ~190 KB stays on the markdown page instead of being folded into the shared vendor chunk every viewer loads on open. The markdown page budget in check-webviews-diff-budget.mjs is raised from 1.2 MB to 1.4 MB, with a comment tying the headroom to that server renderer.

Committed Resources/markdown-viewer/webviews-app chunks are regenerated from the new split (smaller shared vendor, server code colocated with markdown).

Reviewed by Cursor Bugbot for commit 606e3684cb58c09f5b03e0cd620e7aad0d10e5b0. Bugbot is set up for automated code reviews on this repo. Configure here.