Summary
The production client build currently emits a large main JavaScript chunk:
dist/assets/index-DtXPVynI.js 1,449.28 kB | gzip: 454.26 kB
Vite warns that the main chunk exceeds the default size threshold. The app still builds and works, but the current bundle shape increases initial download, parse, and execution cost.
Current state
client/src/App.tsx eagerly imports every route
client/src/components/blocks/BlockRenderer.tsx eagerly imports every block type
- heavy visualization dependencies are pulled into the main path:
echarts via client/src/lib/echarts.ts
d3 via FlameGraphBlock and TraceWaterfallBlock
- markdown/rendering helpers through chat rendering
DemoPage is bundled into the main app even though it is only a showcase route
Goal
Reduce initial client JS without making the codebase harder to follow.
Proposed work
- Add route-level lazy loading in
client/src/App.tsx
- lazy load
HomePage, ServicePage, AlertsPage, ChatPage, and DemoPage
- keep a simple
Suspense fallback
- Split heavy block rendering in
client/src/components/blocks/BlockRenderer.tsx
- lazy load the expensive visualization blocks:
TimeseriesBlock
BarBlock
HeatmapBlock
TopologyBlock
SankeyBlock
CorrelationBlock
FlameGraphBlock
TraceWaterfallBlock
- keep lightweight blocks eager
- Isolate
DemoPage completely from the main application chunk
- Rebuild and measure the new chunk layout
- Only if needed after real lazy loading, add
manualChunks in client/vite.config.ts for large vendor groups such as echarts, d3, and markdown-related packages
Non-goal
Do not silence the warning by only increasing chunkSizeWarningLimit. The fix should be actual code-splitting.
Acceptance criteria
- the main entry chunk is materially smaller than the current ~1.45 MB minified output
- route transitions still work correctly
- chart and trace blocks still render correctly when loaded lazily
bun run build passes
- the remaining Vite warning is gone or clearly reduced to a justified vendor split
Summary
The production client build currently emits a large main JavaScript chunk:
Vite warns that the main chunk exceeds the default size threshold. The app still builds and works, but the current bundle shape increases initial download, parse, and execution cost.
Current state
client/src/App.tsxeagerly imports every routeclient/src/components/blocks/BlockRenderer.tsxeagerly imports every block typeechartsviaclient/src/lib/echarts.tsd3viaFlameGraphBlockandTraceWaterfallBlockDemoPageis bundled into the main app even though it is only a showcase routeGoal
Reduce initial client JS without making the codebase harder to follow.
Proposed work
client/src/App.tsxHomePage,ServicePage,AlertsPage,ChatPage, andDemoPageSuspensefallbackclient/src/components/blocks/BlockRenderer.tsxTimeseriesBlockBarBlockHeatmapBlockTopologyBlockSankeyBlockCorrelationBlockFlameGraphBlockTraceWaterfallBlockDemoPagecompletely from the main application chunkmanualChunksinclient/vite.config.tsfor large vendor groups such asecharts,d3, and markdown-related packagesNon-goal
Do not silence the warning by only increasing
chunkSizeWarningLimit. The fix should be actual code-splitting.Acceptance criteria
bun run buildpasses