Back to all fixes
CuratedTypeScriptVite 8local
Dependency pre-bundling causes wrong execution order for CJS side-effect modules
Problem
In Vite 8 dev mode, pre-bundled (optimizeDeps) CommonJS dependencies with internal side effects (e.g. echarts) execute in the wrong order compared to Vite 5/Rollup, causing broken behavior at runtime. Works fine in production build; only dev server pre-bundling is affected.
Solution
typescript
Workaround (any Vite 8.0.x): set `optimizeDeps.rolldownOptions.output.strictExecutionOrder: true` in vite.config.ts to force Rolldown's pre-bundling to preserve original module execution order. Confirmed fixed upstream in Vite 8.0.14+ (rolldown pre-bundling order fix) - upgrading removes the need for the option.