Findings No. 114
esbuild does not emit a `.wasm` named by `new URL(..., import.meta.url)`, and stops on Emscripten's Node import
A plain esbuild bundle of an Emscripten module emits no .wasm and needs --external:node:*. Vite 8 emits the file. A package that loads an asset this way needs a fallback.
esbuild does not follow new URL("...", import.meta.url), so a WebAssembly file referenced that way is not emitted with the bundle. It also stops on the await import("node:module") in Emscripten's glue code unless --external:node:* is given.
We checked this before making @barmark/score load @barmark/engraver, our lighter build of Verovio, whose size saving comes from keeping its .wasm in a separate file. With Vite 8.3.5, a worker importing it emitted verovio-module-<hash>.wasm beside the worker chunk, and Chromium engraved with it. With esbuild 0.27 and --bundle --format=esm, the build stopped on the Node import. Given the external flag it bundled, but emitted no .wasm. In the browser the module asked for verovio-module.wasm beside itself, got a 404, and engraving failed. Stock Verovio does not have the problem, because it carries its WebAssembly inside the JavaScript.
As written, the plan would have broken any reader who bundles with plain esbuild. Score now falls back to stock Verovio with one warning when the lighter module cannot load, and its README names the flag and the copy step for esbuild.
The general rule: a package that finds an asset through new URL(..., import.meta.url) depends on the reader's bundler. Check it against each bundler you expect readers to use, and give it a fallback.
Receipt: Barmark (packages/score/README.md, "Bundlers and the lighter build"; scripts/score-bundlers.ts), FINDINGS.md, 2026-11-24.