File tree Expand file tree Collapse file tree 9 files changed +87
-9
lines changed Expand file tree Collapse file tree 9 files changed +87
-9
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Unreleased
4
4
5
+ ### HMR did not work for components imported with queries with rolldown-vite ([ #872 ] ( https://github.com/vitejs/vite-plugin-react/pull/872 ) )
6
+
5
7
### Perf: simplify refresh wrapper generation ([ #835 ] ( https://github.com/vitejs/vite-plugin-react/pull/835 ) )
6
8
7
9
## 5.0.2 (2025-08-28)
Original file line number Diff line number Diff line change @@ -144,8 +144,8 @@ export default function viteReact(opts: Options = {}): Plugin[] {
144
144
// if development is enabled and those properties are already present
145
145
development : false ,
146
146
} ,
147
- jsxRefreshInclude : include ,
148
- jsxRefreshExclude : exclude ,
147
+ jsxRefreshInclude : makeIdFiltersToMatchWithQuery ( include ) ,
148
+ jsxRefreshExclude : makeIdFiltersToMatchWithQuery ( exclude ) ,
149
149
} ,
150
150
}
151
151
} else {
@@ -156,8 +156,8 @@ export default function viteReact(opts: Options = {}): Plugin[] {
156
156
importSource : opts . jsxImportSource ,
157
157
refresh : command === 'serve' ,
158
158
} ,
159
- jsxRefreshInclude : include ,
160
- jsxRefreshExclude : exclude ,
159
+ jsxRefreshInclude : makeIdFiltersToMatchWithQuery ( include ) ,
160
+ jsxRefreshExclude : makeIdFiltersToMatchWithQuery ( exclude ) ,
161
161
} ,
162
162
optimizeDeps : {
163
163
rollupOptions : { transform : { jsx : { runtime : 'automatic' } } } ,
Original file line number Diff line number Diff line change 1
1
import React , { useState } from 'react'
2
+ import WithQuery from './components/WithQuery?qs-should-not-break-plugin-react'
2
3
3
4
function App ( ) {
4
5
const [ count , setCount ] = useState ( 0 )
@@ -23,6 +24,8 @@ function App() {
23
24
Learn React
24
25
</ a >
25
26
</ header >
27
+
28
+ < WithQuery />
26
29
</ div >
27
30
)
28
31
}
Original file line number Diff line number Diff line change @@ -18,6 +18,28 @@ test.runIf(isServe)('should hmr', async () => {
18
18
expect ( await page . textContent ( 'button' ) ) . toMatch ( 'count is: 1' )
19
19
} )
20
20
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
+
21
43
test . runIf ( isServe ) (
22
44
'should have annotated jsx with file location metadata' ,
23
45
async ( ) => {
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change 1
1
import { useState } from 'react'
2
2
import Button from 'jsx-entry'
3
- import Dummy from './components/Dummy ?qs-should-not-break-plugin-react'
3
+ import WithQuery from './components/WithQuery ?qs-should-not-break-plugin-react'
4
4
import { Accordion } from './components/Accordion'
5
5
import Parent from './hmr/parent'
6
6
import { JsxImportRuntime } from './hmr/jsx-import-runtime'
@@ -39,7 +39,7 @@ function App() {
39
39
</ a >
40
40
</ header >
41
41
42
- < Dummy />
42
+ < WithQuery />
43
43
< Accordion . Root >
44
44
< Accordion . Item > First Item</ Accordion . Item >
45
45
< Accordion . Item > Second Item</ Accordion . Item >
Original file line number Diff line number Diff line change @@ -35,6 +35,28 @@ test.runIf(isServe)('should hmr', async () => {
35
35
await expect . poll ( ( ) => page . textContent ( 'h1' ) ) . toMatch ( 'Hello Vite + React' )
36
36
} )
37
37
38
+ test . runIf ( isServe ) ( 'should hmr files with queries' , async ( ) => {
39
+ expect ( await page . textContent ( '#WithQuery' ) ) . toBe ( 'With Query' )
40
+
41
+ expect ( await page . textContent ( '#WithQuery-button' ) ) . toMatch ( 'count is: 0' )
42
+ await page . click ( '#WithQuery-button' )
43
+ expect ( await page . textContent ( '#WithQuery-button' ) ) . toMatch ( 'count is: 1' )
44
+
45
+ editFile ( 'components/WithQuery.jsx' , ( code ) =>
46
+ code . replace ( 'With Query' , 'With Query Updated' ) ,
47
+ )
48
+ await expect
49
+ . poll ( ( ) => page . textContent ( '#WithQuery' ) )
50
+ . toBe ( 'With Query Updated' )
51
+ // preserve state
52
+ expect ( await page . textContent ( '#WithQuery-button' ) ) . toMatch ( 'count is: 1' )
53
+
54
+ editFile ( 'components/WithQuery.jsx' , ( code ) =>
55
+ code . replace ( 'With Query Updated' , 'With Query' ) ,
56
+ )
57
+ await expect . poll ( ( ) => page . textContent ( '#WithQuery' ) ) . toBe ( 'With Query' )
58
+ } )
59
+
38
60
test . runIf ( isServe ) ( 'should not invalidate when code is invalid' , async ( ) => {
39
61
editFile ( 'App.jsx' , ( code ) =>
40
62
code . replace ( '<div className="App">' , '<div className="App"}>' ) ,
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import { 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
+ }
You can’t perform that action at this time.
0 commit comments