Rollup dynamic import chunking: opaque boundary determination and size limits
20.5K reputation · 02 May 2026, 04:57 UTC
Automatic Chunking Behavior
Rollup automatically creates separate chunks for modules imported via dynamic import(). However, the internal algorithm used to determine which modules share a chunk remains opaque, and the tool does not enforce a default maximum chunk size.
Constraints and Uncertainty
While output.manualChunks allows for explicit grouping, it requires manual dependency analysis. In large projects, this can lead to chunks that exceed network transfer thresholds or unexpected duplication of dependencies when multiple dynamic imports reference the same module.
Technical Questions
- Does the automatic chunking algorithm consider module size when grouping, or is it based strictly on import relationships?
- Is there a mechanism to define a maximum size threshold for automatically generated chunks?
- Under what conditions does Rollup duplicate shared dependencies across dynamic chunks instead of consolidating them?