From 94fc7371daf44ae104a24baeceb44cdb5d9bbb82 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 9 Aug 2025 11:45:40 +0900 Subject: [PATCH 1/2] fix(react): auto disable react-compiler on non client envrionment --- packages/plugin-react/src/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index 7ee6535ea..87d00b167 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -245,6 +245,14 @@ export default function viteReact(opts: Options = {}): Plugin[] { })() const plugins = [...babelOptions.plugins] + // remove react-compiler plugin on non client environment + if (ssr) { + const reactCompilerPlugin = getReactCompilerPlugin(plugins) + if (reactCompilerPlugin) { + plugins.splice(plugins.indexOf(reactCompilerPlugin), 1) + } + } + const isJSX = filepath.endsWith('x') const useFastRefresh = !skipFastRefresh && From fc8ba7aef7621d7778fa02ce8e09c908cbde5922 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 9 Aug 2025 11:48:04 +0900 Subject: [PATCH 2/2] test: update --- packages/plugin-rsc/e2e/react-compiler.test.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/plugin-rsc/e2e/react-compiler.test.ts b/packages/plugin-rsc/e2e/react-compiler.test.ts index de8e9c52e..2c36e24b5 100644 --- a/packages/plugin-rsc/e2e/react-compiler.test.ts +++ b/packages/plugin-rsc/e2e/react-compiler.test.ts @@ -22,12 +22,7 @@ test.describe(() => { const overrideConfig = defineConfig({ plugins: [ - react({ - babel: { plugins: ['babel-plugin-react-compiler'] }, - }).map((p) => ({ - ...p, - applyToEnvironment: (e) => e.name === 'client', - })), + react({ babel: { plugins: ['babel-plugin-react-compiler'] } }), rsc(), ], })