Skip to content
Latchkey

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.

rollup output
(!) 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
// 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

  1. For each empty-chunk warning, find the manualChunks branch producing that name.
  2. Delete the branch or fix its condition so it only fires for modules that exist.
  3. Avoid putting first-party modules that import the entry into a vendor chunk.

How to prevent it

  • Keep manualChunks limited to node_modules vendor splitting.
  • Return undefined for modules you want Rollup to chunk automatically.
  • Treat empty-chunk and circular-chunk warnings as build errors in CI.

Frequently asked questions

What causes ""Generated an empty chunk""?
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.
How do I fix "Generated an empty chunk"?
Restrict manualChunks to node_modules and return undefined for everything else so Rollup chunks the rest automatically.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card