Skip to content

Dep optimizer (1.0.2 regression): chunk calls cross-chunk init_*() without importing it → ReferenceError #9515

@JoseGoncalves

Description

@JoseGoncalves

Summary

When rolldown powers Vite 8's dependency optimizer, a generated chunk can call a lazily-initialized cross-chunk init_*() function without importing or declaring it, throwing Uncaught ReferenceError: init_runtime_dom_esm_bundler is not defined at runtime. This is a regression between rolldown 1.0.1 (Vite 8.0.13, correct) and 1.0.2 (Vite 8.0.14, broken).

Note: this surfaces via Vite 8.0.14's optimizeDeps (Vite 8 runs rolldown as its dependency pre-bundler), but the faulty code generation — the missing import for an init_* function that is still called — is rolldown's. Filing here for that reason; cross-reference to Vite for context: https://github.com/vitejs/vite (the rolldown bump landed in vite 8.0.14).

Environment

  • rolldown 1.0.2, bundled by vite 8.0.14 (via @quasar/app-vite 2.6.0)
  • node 22.22.2, npm 11.15.0, Linux x86_64

Details

The app uses Vue 3 + vue-i18n plus several larger deps (echarts, vue-echarts, vue3-google-map, vue-pdf-embed, vue-currency-input). With enough modules in the optimize pass, the optimizer splits Vue's runtime into separate lazily-initialized sub-chunks (reactivity, runtime-core, runtime-dom, shared), each wrapped in an __esmMin init function.

In the generated vue-i18n.js chunk, the module prelude calls all four:

init_runtime_dom_esm_bundler(), init_reactivity_esm_bundler(), init_runtime_core_esm_bundler(), init_shared_esm_bundler();

but the chunk only imports two of them from the runtime-dom chunk:

import { , Ln as init_reactivity_esm_bundler, , St as init_runtime_core_esm_bundler,  } from "./runtime-dom.esm-bundler-<hash>.js";

init_runtime_dom_esm_bundler (exported by the runtime-dom chunk as u) and init_shared_esm_bundler are called but never importedReferenceError. Every other consumer chunk (vue.js, @vueuse/core, quasar.client.js, vue3-google-map.js) imports it correctly — only the vue-i18n chunk drops the binding. It looks like the import for the init prelude is pruned while the call is kept (perhaps assuming it's already initialized transitively).

Reproduction conditions

  • Vite 8 project (optimizeDeps via rolldown)
  • vue + vue-i18n, plus enough additional deps in the optimize pass to force Vue's runtime to split into multiple init_* sub-chunks. In a minimal project Vue stays a single chunk and the bug doesn't appear.

Expected

Each chunk imports every init_* function it calls.

Actual

init_runtime_dom_esm_bundler / init_shared_esm_bundler are called without being imported.

Workaround

Pin rolldown to 1.0.1 (npm overrides) while staying on vite 8.0.14 — verified to restore correct imports.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions