Back to all fixes
CuratedExecution-verifiedTypeScriptVite 8local

Vite 8 no longer replaces global define with undefined in CJS output

Problem

A CJS library that uses an AMD/UMD-style `typeof define === 'function'` runtime check (e.g. via @paciolan/remote-module-loader) behaves differently after upgrading to Vite 8: code paths that used to be dead-code-eliminated because Rollup's commonjs plugin replaced `define` with `undefined` now execute, since Rolldown (like esbuild) does not perform that substitution.

Solution

typescript
This is an intentional behavior change, not a bug: Rolldown matches esbuild's behavior of leaving a global `define` reference alone (a user or another package can legitimately define it), whereas Vite 7's @rollup/plugin-commonjs hardcoded it to undefined. There is no vite.config flag to restore the old behavior. Fix at the source: update or patch the offending library to not rely on `define` being unset in CJS builds - the reporter's case was resolved by a fix in the downstream package itself.