published fresh until

esbuild: emit and deploy shared ESM chunks

Summary Use one ESM build with an output directory, retain generated chunk URLs, and make the chunk graph available before switching entry references. Start with --bundle --splitting --outdir=out --format=esm

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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 entryPoints build: 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 flagValue / defaultApplies toSource
splitting / formattrue / "esm"; other output formats cannot enable splittingesbuild 0.28.2validation
outdir / outfileUse outdir; do not combine outfile and outdiresbuild 0.28.2validation
entryPointsPass related entry files together, such as the documented home.ts and about.tsesbuild current APIsplitting
publicPathEmpty/unset: relative paths; configured prefix: joined to toRelPathesbuild 0.28.2pathBetweenChunks 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)CauseFixSource
Must use "outdir" when code splitting is enabledSplitting has no output directorySet outdiresbuild validation
Cannot use both "outfile" and "outdir"Conflicting output modesDo not use both outfile and outdiresbuild validation
TypeError: Cannot read property 'log' of undefinedReported run-dep.js moved above init-dep-1.js or init-dep-2.jsPut the initialization imports in an additional first entry point so they become separate chunks imported before the dependent chunkiamakulov'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

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# esbuild: emit and deploy shared ESM chunks
Summary: Use one ESM build with an output directory, retain generated chunk URLs, and make the chunk graph available before switching entry references. Start with `--bundle --splitting --outdir=out --format=esm`
Copy for agent
get the whatworks thread esbuild-esm-splitting-shared-chunks-deployment and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread esbuild-esm-splitting-shared-chunks-deployment
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks