Rollup manualChunks "Generated an empty chunk" / Circular Warnings
A custom output.manualChunks assigned modules to a chunk in a way Rollup could not honor - producing an empty chunk, breaking the load order, or causing a circular-chunk warning. The chunking function is the cause, not your source.
What this error means
A vite build/rollup run warns Generated an empty chunk: "<name>", or emits chunks that fail to load in the browser (a vendor chunk importing the entry, or initialization-order errors). It surfaces only when manualChunks is configured.
(!) Generated an empty chunk: "vendor".
(!) Circular dependency: chunk "vendor" -> chunk "index" -> chunk "vendor"
rendering chunks...Common causes
A chunk name matches no real modules
A manualChunks branch returns a chunk name for a condition that never matches (or matched modules were tree-shaken away), so Rollup emits an empty chunk.
Mis-grouping creates a circular chunk graph
Putting modules that depend on the entry into a "vendor" chunk (or splitting a strongly-connected module group across chunks) creates circular chunk imports and load-order bugs.
How to fix it
Group only stable third-party modules
Restrict manualChunks to node_modules and return undefined for everything else so Rollup chunks the rest automatically.
// vite.config.ts
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) return 'vendor'
// return undefined -> let Rollup decide
},
},
},
}Remove names that match nothing
- For each empty-chunk warning, find the
manualChunksbranch producing that name. - Delete the branch or fix its condition so it only fires for modules that exist.
- Avoid putting first-party modules that import the entry into a vendor chunk.
How to prevent it
- Keep
manualChunkslimited tonode_modulesvendor splitting. - Return
undefinedfor modules you want Rollup to chunk automatically. - Treat empty-chunk and circular-chunk warnings as build errors in CI.