Back to all fixes
CuratedTypeScriptVite 8local

const require_X = require_X() self-reference crash when bundling CJS deps (e.g. es-toolkit)

Problem

Build output contains a self-referential statement like `const require_identity = require_identity();` which throws at runtime. Triggered when bundling a CJS dependency (e.g. es-toolkit) whose own dist files declare local variables using the same `require_<name>` naming convention that rolldown uses internally for its generated require-helpers. When such a helper is referenced across chunks, rolldown keeps the original (non-deconflicted) name, colliding with the source-level local of the same name.

Solution

typescript
Fixed in rolldown: landed in PR #9648 (an earlier attempt in PR #9392 did not fully fix it). Upgrade to the rolldown/vite release published after that PR merged — a maintainer confirmed the patch would ship in the next release (roughly the release following rolldown 1.1.2). If you must stay on an older rolldown version, avoid or patch dependencies whose CJS build emits locals named `require_<something>`.