fix(build): merge React vendors into one chunk to fix white screen - #3938
Merged
Conversation
- Production manualChunks split react/@arco/markdown/highlight/editor into separate vendor chunks, forming circular ESM chunk imports (vendor-editor -> vendor-highlight -> vendor-arco -> vendor-react -> vendor-editor). Evaluation order left React's exports uninitialized when vendor-arco ran React.createContext, throwing "Cannot read properties of undefined (reading 'createContext')" and leaving #root empty — a full white screen in every packaged/served build (desktop dmg, WebUI switch, aionui-web all serve out/renderer). - Co-locate react/react-dom/@arco-design/markdown/highlight/editor/katex into a single `vendor` chunk, removing the cross-chunk cycle. A single vendor chunk loads from disk (file://) so the extra granularity added nothing but the cycle. - Verified: bun run package emits zero circular-chunk warnings; production build + WebUI at 390px no longer white; text/image/pdf/office previews all render.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Description
Fixes a full white screen in every packaged / statically-served build (desktop
dmg+electron-vite preview, the WebUI toggle, andaionui-web).Root cause (build-level, on
main).packages/desktop/electron.vite.config.tsmanualChunkssplit React and its tightly-coupled vendors into separate chunks (vendor-react,vendor-arco,vendor-highlight,vendor-markdown,vendor-editor), producing circular ESM chunk imports:With a chunk cycle, ESM evaluation order left React's exports uninitialized when
vendor-arco's top level ranReact.createContext, throwing:#rootstayed empty → 100% white screen. Dev (bun start) is immune because Vite serves unbundled ESM (nomanualChunks). All three production consumers serve the sameout/renderer, so all three white-screen.Fix. Co-locate
react/react-dom/@arco-design/ markdown / highlight / editor /katexinto a singlevendorchunk, removing the cross-chunk cycle. A single vendor chunk loads from disk (file://) so the extra granularity bought nothing but the cycle.Type of Change
fix— Bug fix (non-breaking change which fixes an issue)Atomic PR Checklist (Rule 1)
Local Checks (Rule 3)
bun run format— passes (viajust push)bun run lint— 0 errors (viajust push)bunx tsc --noEmit— passes (viajust push)bunx vitest run— 3964 passed / 5 skipped (viajust push)just push)Runtime Verification
Verified on macOS:
bun run package→ zero circular-chunk warnings (was 2); single mergedvendorchunk.electron-vite preview,file://out/renderer) at 390px:#rootnon-empty, React mounts, no longer white (wasrootLen=0/ 100% white /createContextcrash).bun run webui) at 390px: renders, React mounts.Additional Context
Chunk-boundary / build-config only; no runtime/source behavior change. Unblocks the mobile WebUI file-preview goal (that path serves the same
out/renderer).