What this thread does
Do first: build related entries together with --bundle --splitting --outdir=out --format=esm.
Short answer
As of November 2026, esbuild 0.28.2 is current (release). Splitting requires ESM and an output directory; it extracts shared dependencies and lazy import() targets (API).
Choose / don't choose
- One
entryPointsbuild: choose for related entries sharing dependencies (API). - Separate builds: choose for independently deployed artifacts or different runtime constraints; don't assume matching source dependencies produce interchangeable chunk filenames.
Not for: choosing Vite or another application bundler; see vite-8-esbuild-turbopack-webpack-or-tsdown-for-js-builds-2026.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
splitting / format | true / "esm"; other output formats cannot enable splitting | esbuild 0.28.2 | validation |
outdir / outfile | Use outdir; do not combine outfile and outdir | esbuild 0.28.2 | validation |
entryPoints | Pass related entry files together, such as the documented home.ts and about.ts | esbuild current API | splitting |
publicPath | Empty/unset: relative paths; configured prefix: joined to toRelPath | esbuild 0.28.2 | pathBetweenChunks implementation |
Order of operations
1. Build once and inspect the emitted entry's exact chunk imports. Preserve the relative output tree at the public asset location, or choose the prefix appropriate to that location. The linker's pathBetweenChunks joins with the public path if configured (implementation). 2. Deployment policy inferred from the generated graph: upload all referenced hashed chunks first, then entry files, then switch HTML/manifests to those entries. An atomic deployment of the complete graph is another valid policy. Do not expose a new reference before its target is available. 3. Retain old chunks while old entries may still be cached or open in browsers. Vite's load-error guidance documents an import error for a returning user when a hosting service deletes assets from previous deployments. It is corroboration for the retention policy, not an esbuild deployment command. 4. Inspect the actual failed request URL against the emitted import, prefix and deployed output path. A missing file or obsolete cached entry needs deployment/retention correction, not a change from ESM to CommonJS.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
Must use "outdir" when code splitting is enabled | Splitting has no output directory | Set outdir | esbuild validation |
Cannot use both "outfile" and "outdir" | Conflicting output modes | Do not use both outfile and outdir | esbuild validation |
TypeError: Cannot read property 'log' of undefined | Reported run-dep.js moved above init-dep-1.js or init-dep-2.js | Put the initialization imports in an additional first entry point so they become separate chunks imported before the dependent chunk | iamakulov's September 20, 2020 report |
The API documents an ordering issue with imports across code splitting chunks. Tracker1's February 17, 2020 feature thread describes the shared/lazy split goals; it does not establish a fixed-in release for ordering.
Missing
- The linked source does not confirm: Independent builds cannot share a common generated chunk graph.
- No universal CDN retention duration or deployment command follows from esbuild; the maximum lifetime of old entries depends on the host and caching policy.
Checked
2026-11-12; esbuild 0.28.2 release and validation/linker sources, current API, tracker1/iamakulov discussions and Vite asset-retention guidance read. No builds or deployments executed.
Started from a post by @Evan Wallace, packaged by the editor. Original post