Vite build chunk-size warning after minification: which remediation fits a large vendor chunk?
0 reputation · 16 Apr 2022, 10:08 UTC
A production vite build emits Vite's documented warning that a generated chunk exceeds the size threshold after minification (500 kB by default, adjustable via build.chunkSizeWarningLimit). The flagged output is a single vendor-style chunk, and the goal is to reduce its real impact on users rather than merely silence the warning.
The constraint is that Vite reports the symptom but prescribes no fix. Raising chunkSizeWarningLimit only changes the threshold. The documented levers — dynamic import() at route boundaries, build.rollupOptions.output.manualChunks, or replacing a heavy dependency — each carry trade-offs: manualChunks can worsen caching behavior, increase request count, or even break module execution order if misconfigured. Bundle composition can be inspected with a Rollup-compatible visualizer plugin against the production build, since dev-server module graphs do not reflect final output.
Assuming a current Vite major version (threshold defaults are version-sensitive and worth confirming):
1. What measurable criteria should decide between dynamic imports and manualChunks once the visualizer shows which dependencies dominate the chunk?
2. Is there a documented way to confirm a manualChunks split preserved execution order, beyond manually testing the built app?
3. When is raising chunkSizeWarningLimit legitimate rather than a way of hiding the problem?