[Frontend] Route-level code splitting #105
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
src/App.jsx:5-21eagerly imports all 20 pages, so every route ships in one bundle. The heaviest:CampaignDetail.jsx(2376 lines),WikiArticle.jsx(2115 lines — the sole consumer ofreact-markdown, imported atWikiArticle.jsx:13, which drags micromark/mdast into the main chunk), andAdmin.jsx(1487 lines). There is noReact.lazy/Suspenseanywhere and nomanualChunksinvite.config.js.Motivation
A player opening the dashboard downloads the entire admin panel and the full markdown toolchain first. Route-level splitting is the single cheapest bundle win available and a prerequisite for reasonable PWA caching.
Fix / Spec
src/App.jsxtoReact.lazy(() => import(...))and wrap the route outlet in a<Suspense>with a fallback (reuse the app's existing loading UI/spinner rather than inventing a new one).Login) eager if it helps first paint — judgement call, document the choice.react-markdown/micromark land only in the WikiArticle chunk (checkvite buildoutput orrollup-plugin-visualizerlocally; do not commit the visualizer).vite buildchunk sizes in the PR description.findBy*instead ofgetBy*, or a Suspense-aware render helper).Acceptance criteria
react-markdownis absent from the entry chunk.vite previewsmoke check).References
src/App.jsx:5-21src/pages/WikiArticle.jsx:13(react-markdown import)vite.config.jsFiled from the July 2026 full-project review.