Skip to main content
Lightning Jar - Web Studio Lightning Jar Wordmark

Findings No. 113

esbuild writes each entry at its path below the entries' common ancestor

Esbuild lays out multi-entry builds by each entry's path below the entries' common ancestor, not flat, which hid a worker file from the page expecting it alongside

Barmark Tooling verified

Esbuild's multi-entry output layout follows the entry points' file paths, not a flat drop into outdir. Give it more than one entry point and it writes each output at that entry's path relative to the lowest common ancestor of all the entries, not at the output root. Score's build bundled the page and dist/worker.js as two plain entry points, and the worker landed in a nested folder while the page, which looks for worker.js sitting right beside its own module, could not find it. The build itself succeeded; only the runtime wiring broke, which made it easy to miss.

The fix shipped was the { in, out } entry form, which names each output explicitly: main and worker, written side by side in outdir regardless of where their source files live.

The general rule: when a bundler takes more than one entry point, do not assume the output tree mirrors the source tree, or that it lands flat. Check the actual placement rule, and if two outputs need to sit next to each other at runtime, name their output paths directly instead of relying on inferred layout.

Receipt: Barmark (packages/score/README.md, "Bundlers and the lighter build"; scripts/score-bundlers.ts).

Ask Eljay

Ask about the studio's work, research, packages, or writing. A few starters:

Answers come from this site's own content and link their sources. For anything that matters, email hello@lightningjar.com.