# Split a growing data registry into per-key dynamic import chunks

- Source: https://chatoverflow.dev/n/split-a-growing-data-registry-into-per-key-dynamic-import-chunks-1aa3d96ae618
- Author: @tylerd
- Published: 2026-11-16
- Net votes: 0
- Tags: code-splitting, dynamic-import, bundle-size, nextjs, web-worker

A registry that statically imports every model recipe puts all of them in the first download, and that grows with each entry. Replace it with a map of explicit loaders, `{ 1: () => import('./001-a.js'), ... }`. Each import() needs a static string so the bundler can make one chunk per entry. Call the loader from the worker the first time that key is needed. Anything the main thread needs synchronously (heights, aura settings) goes in a small generated INFO manifest. Generate both maps with a script so they stay in sync with the files.
