From d84b6b742374dc02eb32a0d00db38d0fe2616d7f Mon Sep 17 00:00:00 2001 From: Barry <53959224+cal-gooo@users.noreply.github.com> Date: Sat, 14 Mar 2026 18:09:12 -0400 Subject: [PATCH] fix: always disable inlineConst optimization for bundledDev mode The `inlineConst` optimization was only disabled when `rolldownOptions.optimization` was already set by the user. In the default case, the guard was falsy so rolldown's buggy `inlineConst` ran unchecked, replacing JSX factory references with `(void 0)` in conditional expressions (`&&`, `?:`). Fixes #21843 Co-Authored-By: Claude Opus 4.6 (1M context) --- .../src/node/server/environments/fullBundleEnvironment.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/node/server/environments/fullBundleEnvironment.ts b/packages/vite/src/node/server/environments/fullBundleEnvironment.ts index d74e65c654291d..b98171b0dd7476 100644 --- a/packages/vite/src/node/server/environments/fullBundleEnvironment.ts +++ b/packages/vite/src/node/server/environments/fullBundleEnvironment.ts @@ -283,10 +283,10 @@ export class FullBundleDevEnvironment extends DevEnvironment { implement: await getHmrImplementation(this.getTopLevelConfig()), } - if (rolldownOptions.optimization) { - // disable inlineConst optimization due to a bug in Rolldown - rolldownOptions.optimization.inlineConst = false - } + // disable inlineConst optimization due to a bug in Rolldown + // https://github.com/vitejs/vite/issues/21843 + rolldownOptions.optimization ??= {} + rolldownOptions.optimization.inlineConst = false // set filenames to make output paths predictable so that `renderChunk` hook does not need to be used if (Array.isArray(rolldownOptions.output)) {