Back to all fixes
CuratedTypeScriptVite 8local

Vite 8.0.14+ throws 'X is not defined' for cross-chunk top-level side-effect calls

Problem

Uncaught ReferenceError: init_reactivity_esm_bundler is not defined (or a similarly named helper/identifier, e.g. Router, checkReady) at runtime after a Vite 8 production build, once the app has enough entry points/chunks for Rolldown's cross-chunk import wiring to kick in. Affects Vue apps and non-Vue libraries alike that have top-level side-effect calls depending on an import from another chunk. Regression appeared between vite@8.0.10 (working) and vite@8.0.14 (broken).

Solution

typescript
Root cause fixed upstream (rolldown/rolldown#9502, merged via rolldown/rolldown#9717) and included in Vite 8.1.0 - upgrade to vite@8.1.0+. For versions between 8.0.14 and 8.1.0, pin `"overrides": { "rolldown": "1.0.1" }` in package.json as a temporary downgrade workaround. Note: some users still saw a similar ReferenceError on 8.1.0/8.1.1 in more complex multi-plugin builds (e.g. Capacitor/Framework7) - if it recurs after upgrading, treat as a fresh issue needing its own minimal repro.