From 126167e6c4538084526a09b516f68ccded1ad75b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnaud=20Barr=C3=A9?= Date: Mon, 2 Nov 2026 08:49:23 +0100 Subject: [PATCH] fix(plugin-react): fix new refreshInclude option --- packages/plugin-react/CHANGELOG.md | 4 ++++ packages/plugin-react/src/index.ts | 10 ++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/plugin-react/CHANGELOG.md b/packages/plugin-react/CHANGELOG.md index e02a02e49..b8820897d 100644 --- a/packages/plugin-react/CHANGELOG.md +++ b/packages/plugin-react/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Fix `refreshInclude` and `refreshExclude` options not working ([#1543](https://github.com/vitejs/vite-plugin-react/pull/1543)) + +Fix mistake from #1516 + ## 6.2.0 (2026-11-02) ### Add `refreshInclude` and `refreshExclude` options ([#1516](https://github.com/vitejs/vite-plugin-react/pull/1516)) diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index 9a0ad45d1..102ae2db5 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -375,19 +375,17 @@ function createReactCompilerPlugin( }, }, async handler(code, id) { - // Follow what the builtin oxc plugin does: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/oxc.ts#L250-L267 const [filepath] = id.split('?') const isJSX = filepath.endsWith('x') const isClient = this.environment?.config.consumer !== 'server' const refreshEnabled = isClient && isFastRefreshEnabled() && - ((jsxRefreshFilter && !jsxRefreshFilter(id)) || - !( - isJSX || + (jsxRefreshFilter + ? jsxRefreshFilter(id) + : isJSX || code.includes(jsxImportRuntime) || - code.includes(jsxImportDevRuntime) - )) + code.includes(jsxImportDevRuntime)) const shouldCompile = isClient &&