Back to all fixes
CuratedTypeScriptVite 8local
Vite 8 production build strips optional chaining from imported bindings
Problem
TypeError: Cannot read properties of undefined (reading 'x') after a production build with Vite 8, on code using optional chaining (obj?.prop) against a value imported from another module (e.g. a Svelte $state export). The `?.` is silently removed by the minifier/bundler, turning it into an unguarded property access. Not reproducible in dev mode or Vite 7.1.x.
Solution
typescript
Confirmed Rolldown/Oxc bug (tracked at rolldown/rolldown#8710), not an application bug. The Vite issue was closed as completed after the upstream fix landed - upgrade to the latest Vite 8.x / bundled Rolldown to get corrected optional-chaining handling. No vite.config workaround; downgrading to Vite 7 avoids it until you upgrade.