Skip to content

fix(plugin-react): enable Fast Refresh for JSX files with the compiler - #1524

Open
kklem0 wants to merge 1 commit into
vitejs:mainfrom
kklem0:fix/compiler-refresh-condition
Open

kklem0 wants to merge 1 commit into
vitejs:mainfrom
kklem0:fix/compiler-refresh-condition

Conversation

@kklem0

@kklem0 kklem0 commented Oct 21, 2026

Copy link
Copy Markdown

Description

#1516 inverted the refresh condition of the compiler plugin. Without refreshInclude / refreshExclude, refresh is now only enabled for files that are not JSX and do not import the JSX runtime, and with them, only for the files the filter excludes:

((jsxRefreshFilter && !jsxRefreshFilter(id)) ||
  !(isJSX || code.includes(jsxImportRuntime) || code.includes(jsxImportDevRuntime)))

So with react({ compiler: true }) on main:

This restores the condition from before #1516 and applies the refresh filter on top of it:

(!jsxRefreshFilter || jsxRefreshFilter(id)) &&
  (isJSX || code.includes(jsxImportRuntime) || code.includes(jsxImportDevRuntime))

The two new unit tests run the compiler transform in serve mode and fail on main: one checks that a .tsx component gets $RefreshReg$ and a .ts hook gets no $RefreshSig$, the other that refreshInclude / refreshExclude include and exclude files.

No changelog entry, since #1516 is not released yet.

Found while rebasing #1467.

🤖 Generated with Claude Code

The refresh condition of the compiler plugin was inverted in vitejs#1516, so
JSX files got no Fast Refresh and non-JSX files got the refresh
transform again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant