Back to all fixes
CuratedTypeScriptVite 8local
Uncaught ReferenceError: init_runtime_dom_esm_bundler is not defined after rolldown 1.0.3 upgrade
Problem
Browser throws `Uncaught ReferenceError: init_runtime_dom_esm_bundler is not defined` (or similarly-named `init_*` helper) in a production build, e.g. a Vue 3 app using reka-ui/@vueuse. Regression appears between rolldown 1.0.2 (fine) and rolldown 1.0.3 (broken). Rolldown's tree-shaker correctly deletes an unused `init_*` CJS-interop wrapper function (because the module was eagerly inlined elsewhere), but fails to also remove the call sites that still reference it, leaving a dangling free-variable call. Only occurs when tree-shaking is enabled.
Solution
typescript
Confirmed interim workaround shipped by an affected user: add a `renderChunk` plugin that scans the emitted chunk for `init_*` identifiers that are referenced but never declared or imported, and appends hoisted no-op stubs (`function init_x(){}`) for each so the minifier dead-code-eliminates the now-harmless calls (only safe because the underlying module is provably already eagerly initialized). Blunter fallback workaround: set `build.rollupOptions.treeshake = false` to disable tree-shaking entirely (larger bundle, but avoids the bug). No fixed-in-version was confirmed in the thread at time of writing.