Skip to content

Commit 26bb18a

Browse files
authored
Merge branch 'main' into 09-17-ci_use_trusted_publisher
2 parents 89417cb + 8293cb3 commit 26bb18a

14 files changed

Lines changed: 96 additions & 12 deletions

File tree

packages/plugin-react-oxc/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
## 0.4.2 (2025-09-17)
6+
57
### Perf: simplify refresh wrapper generation ([#835](https://github.com/vitejs/vite-plugin-react/pull/835))
68

79
## 0.4.1 (2025-08-19)

packages/plugin-react-oxc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vitejs/plugin-react-oxc",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"license": "MIT",
55
"author": "Evan You",
66
"contributors": [

packages/plugin-react-swc/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
## 4.1.0 (2025-09-17)
6+
57
### Set SWC cacheRoot options
68

79
This is set to `{viteCacheDir}/swc` and override the default of `.swc`.

packages/plugin-react-swc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vitejs/plugin-react-swc",
3-
"version": "4.0.1",
3+
"version": "4.1.0",
44
"license": "MIT",
55
"author": "Arnaud Barré (https://github.com/ArnaudBarre)",
66
"description": "Speed up your Vite dev server with SWC",

packages/plugin-react/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
## 5.0.3 (2025-09-17)
6+
7+
### HMR did not work for components imported with queries with rolldown-vite ([#872](https://github.com/vitejs/vite-plugin-react/pull/872))
8+
59
### Perf: simplify refresh wrapper generation ([#835](https://github.com/vitejs/vite-plugin-react/pull/835))
610

711
## 5.0.2 (2025-08-28)

packages/plugin-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vitejs/plugin-react",
3-
"version": "5.0.2",
3+
"version": "5.0.3",
44
"license": "MIT",
55
"author": "Evan You",
66
"description": "The default Vite plugin for React projects",

packages/plugin-react/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ export default function viteReact(opts: Options = {}): Plugin[] {
144144
// if development is enabled and those properties are already present
145145
development: false,
146146
},
147-
jsxRefreshInclude: include,
148-
jsxRefreshExclude: exclude,
147+
jsxRefreshInclude: makeIdFiltersToMatchWithQuery(include),
148+
jsxRefreshExclude: makeIdFiltersToMatchWithQuery(exclude),
149149
},
150150
}
151151
} else {
@@ -156,8 +156,8 @@ export default function viteReact(opts: Options = {}): Plugin[] {
156156
importSource: opts.jsxImportSource,
157157
refresh: command === 'serve',
158158
},
159-
jsxRefreshInclude: include,
160-
jsxRefreshExclude: exclude,
159+
jsxRefreshInclude: makeIdFiltersToMatchWithQuery(include),
160+
jsxRefreshExclude: makeIdFiltersToMatchWithQuery(exclude),
161161
},
162162
optimizeDeps: {
163163
rollupOptions: { transform: { jsx: { runtime: 'automatic' } } },

playground/react-classic/App.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useState } from 'react'
2+
import WithQuery from './components/WithQuery?qs-should-not-break-plugin-react'
23

34
function App() {
45
const [count, setCount] = useState(0)
@@ -23,6 +24,8 @@ function App() {
2324
Learn React
2425
</a>
2526
</header>
27+
28+
<WithQuery />
2629
</div>
2730
)
2831
}

playground/react-classic/__tests__/react.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,28 @@ test.runIf(isServe)('should hmr', async () => {
1818
expect(await page.textContent('button')).toMatch('count is: 1')
1919
})
2020

21+
test.runIf(isServe)('should hmr files with queries', async () => {
22+
expect(await page.textContent('#WithQuery')).toBe('With Query')
23+
24+
expect(await page.textContent('#WithQuery-button')).toMatch('count is: 0')
25+
await page.click('#WithQuery-button')
26+
expect(await page.textContent('#WithQuery-button')).toMatch('count is: 1')
27+
28+
editFile('components/WithQuery.jsx', (code) =>
29+
code.replace('With Query', 'With Query Updated'),
30+
)
31+
await expect
32+
.poll(() => page.textContent('#WithQuery'))
33+
.toBe('With Query Updated')
34+
// preserve state
35+
expect(await page.textContent('#WithQuery-button')).toMatch('count is: 1')
36+
37+
editFile('components/WithQuery.jsx', (code) =>
38+
code.replace('With Query Updated', 'With Query'),
39+
)
40+
await expect.poll(() => page.textContent('#WithQuery')).toBe('With Query')
41+
})
42+
2143
test.runIf(isServe)(
2244
'should have annotated jsx with file location metadata',
2345
async () => {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React, { useState } from 'react'
2+
3+
export default function WithQuery() {
4+
const [count, setCount] = useState(0)
5+
return (
6+
<>
7+
<div id="WithQuery">With Query</div>
8+
<button
9+
id="WithQuery-button"
10+
onClick={() => setCount((count) => count + 1)}
11+
>
12+
count is: {count}
13+
</button>
14+
</>
15+
)
16+
}

0 commit comments

Comments
 (0)