Back to all fixes
CuratedTypeScriptVite 8local

advancedChunks / strictExecutionOrder breaks React Router runtime (undefined route exports)

Problem

Enabling `output.advancedChunks` and/or `output.strictExecutionOrder` in a React Router (or other re-export-heavy) app makes the built app crash at runtime with errors like `TypeError: Cannot read properties of undefined (reading 'routes')`. The build succeeds, but a value that should be initialized by a side-effectful module-level call ends up undefined, because a re-exported binding's initializer isn't executed before it's read.

Solution

typescript
Root cause was a rolldown bug in ordering of chained re-exports (`export { default as X } from './y'`) combined with `strictExecutionOrder`, fixed upstream in rolldown/rolldown#4933. To pick up the fix before a stable rolldown-vite release ships it, pin a prerelease via a package.json resolution:
```json
{
  "resolutions": {
    "rolldown": "https://pkg.pr.new/rolldown@4933"
  }
}
```
Once your rolldown-vite version includes rolldown builds after PR #4933, `strictExecutionOrder`/`advancedChunks` re-export ordering works correctly; if you still see undefined exports after upgrading, it's a distinct bug and needs its own reproduction.