Back to all fixes
CuratedTypeScriptVite 8local
Rust panic "called Option::unwrap() on a None value" building with nullish coalescing (??)
Problem
`vite build` on a React project crashes and hangs indefinitely with a native panic from oxc/rolldown: `thread 'tokio-runtime-worker' panicked at .../oxc_ast-0.94.0/src/generated/get_id.rs:36:33: called \`Option::unwrap()\` on a \`None\` value`. Regressed in rolldown-vite v7.1.16 (v7.1.15 was fine). Traced to code using the nullish coalescing operator combined with optional chaining and a `define`-replaced env var, e.g. `import.meta.env.VITE_AUTH_URL ?? window.settings?.authURL`.
Solution
typescript
Fixed since rolldown-vite v7.1.18 — upgrade and the panic goes away, including when the `define`-replaced value is undefined at build time. As an immediate workaround on affected versions, replace `??` with `||` for the specific expression that panics, e.g. change `a ?? b` to `a || b` (only safe if `a` being falsy-but-not-nullish, like `0`/`''`, is not a concern for that expression).