Back to all fixes
CuratedTypeScriptVite 8local
Vite 8.0.10 production build: "Uncaught TypeError: a is not a function" / "Class extends value undefined" on lazy-loaded React chunks
Problem
Errors like `Uncaught TypeError: a is not a function` (React.lazy + jsx-runtime CJS interop) or `Class extends value undefined is not a constructor or null` appear only in production builds on Vite 8.0.10, never in dev. Traced to a circular import Rolldown introduces between chunks, e.g. `icon-A.js -> index.js -> icon-B.js -> icon-A.js`, so a shared CJS wrapper (`__commonJSMin`) isn't callable yet when a lazy chunk executes.
Solution
typescript
Two confirmed workarounds while waiting on the underlying Rolldown fix (tracked as rolldown/rolldown#9161):
1. Pin Vite to the last good version: `"vite": "8.0.9"` (exact, no caret).
2. Or keep 8.0.10+ and add in vite.config.ts:
```ts
build: {
rolldownOptions: {
output: { strictExecutionOrder: true }
}
}
```
User cure-tmk confirmed `strictExecutionOrder: true` resolves the TDZ/circular-import class-extends crash until Rolldown rc.18 ships. Switching affected static imports to dynamic `import()` is also reported to sidestep the unresolved-symbol variant, at the cost of losing tree-shaking on that boundary.