Dynamic import chunking
Slap yourself if
You assume every dynamic import becomes a clean, isolated chunk or believe the bundler always makes the right split for you.
Why this exists
Because dynamic imports are widely used as a performance feature while silently introducing waterfalls, duplication, and execution stalls that teams only notice after shipping.
Mental model
A dynamic import is a hint, not a command. The bundler decides chunk boundaries based on the module graph, cache heuristics, and safety constraints — not your intent.
- A dynamic import creates a potential async boundary in the module graph.
- The bundler groups reachable modules into one or more chunks.
- Shared dependencies may be hoisted or duplicated based on heuristics.
- At runtime, execution pauses until the required chunk graph is fetched and evaluated.
- Assuming one import equals one chunk.
- Triggering nested dynamic imports that serialize network requests.
- Accidentally duplicating large shared dependencies.
- Measuring initial bundle size instead of interaction latency.
Dynamic import chunking is the bundler’s process of grouping asynchronously loaded modules into chunks, trading execution latency and cache behavior for deferred loading.
- Claims dynamic imports always reduce bundle size.
- Cannot explain why multiple imports share a chunk.
- Ignores runtime execution cost.
- Treats chunking as deterministic across tools.
Deep dive
Requires Pro
Premium deep dives include more internals, more scars.