Problem
The app depends on several very large libraries: monaco-editor, 3d-force-graph, cytoscape, react-flow-renderer, @webcontainer/api, and jszip. vite.config.ts sets only build: { target: "esnext" } with no chunking strategy (build.rollupOptions.output.manualChunks). Routes are already lazily imported in src/App.tsx, but these libraries are still liable to be pulled into large shared chunks, so users landing on a simple page (for example a contract or event view) may download the 3D graph and editor code they never use.
What needs to be done
- Measure the current build output (
npm run build) and record the chunk sizes in the issue/PR.
- Add a
manualChunks strategy separating: monaco-editor, the graph libraries (3d-force-graph, cytoscape, react-flow-renderer), and jszip/@webcontainer/api.
- Ensure these libraries are only imported inside the lazily loaded routes that need them (no eager import from shared modules).
- Re-measure and record the improvement.
Files
vite.config.ts
- pages/components importing the heavy libraries
Acceptance deliverables
- Heavy libraries are emitted as separate chunks and are not loaded on routes that do not use them.
- Documented before/after chunk sizes showing an improvement in the initial payload.
Tests to pass
npm run build succeeds and the expected separate chunks are present in dist.
- Existing tests continue to pass.
Problem
The app depends on several very large libraries:
monaco-editor,3d-force-graph,cytoscape,react-flow-renderer,@webcontainer/api, andjszip.vite.config.tssets onlybuild: { target: "esnext" }with no chunking strategy (build.rollupOptions.output.manualChunks). Routes are already lazily imported insrc/App.tsx, but these libraries are still liable to be pulled into large shared chunks, so users landing on a simple page (for example a contract or event view) may download the 3D graph and editor code they never use.What needs to be done
npm run build) and record the chunk sizes in the issue/PR.manualChunksstrategy separating:monaco-editor, the graph libraries (3d-force-graph,cytoscape,react-flow-renderer), andjszip/@webcontainer/api.Files
vite.config.tsAcceptance deliverables
Tests to pass
npm run buildsucceeds and the expected separate chunks are present indist.