File tree 4 files changed +33
-3
lines changed
4 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -102,4 +102,11 @@ if (!isBuild) {
102
102
103
103
expect ( await page . textContent ( '.script' ) ) . toMatch ( '5' )
104
104
} )
105
+
106
+ test ( 'hmr: setup jsx in .vue' , async ( ) => {
107
+ editFile ( 'setup-syntax-jsx.vue' , ( code ) =>
108
+ code . replace ( 'let count = ref(100)' , 'let count = ref(1000)' )
109
+ )
110
+ await untilUpdated ( ( ) => page . textContent ( '.setup-jsx' ) , '1000' )
111
+ } )
105
112
}
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { default as TsxDefault } from './Comp'
4
4
import OtherExt from './OtherExt.tesx'
5
5
import JsxScript from './Script.vue'
6
6
import JsxSrcImport from './SrcImport.vue'
7
-
7
+ import JsxSetupSyntax from './setup-syntax-jsx.vue'
8
8
function App ( ) {
9
9
return (
10
10
< >
@@ -15,6 +15,7 @@ function App() {
15
15
< OtherExt />
16
16
< JsxScript />
17
17
< JsxSrcImport />
18
+ < JsxSetupSyntax />
18
19
</ >
19
20
)
20
21
}
Original file line number Diff line number Diff line change
1
+ <script setup lang="jsx">
2
+ import { ref } from 'vue'
3
+ let count = ref(100)
4
+ const increment = () => {
5
+ count.value++
6
+ }
7
+ const Render = () => (
8
+ <div>
9
+ <button onClick={increment}> click!!! </button>
10
+ </div>
11
+ )
12
+ </script >
13
+
14
+ <template >
15
+ <p class =" setup-jsx" >{{ count }}</p >
16
+ <Render />
17
+ </template >
Original file line number Diff line number Diff line change @@ -40,9 +40,14 @@ export async function handleHotUpdate(
40
40
41
41
if ( hasScriptChanged ( prevDescriptor , descriptor ) ) {
42
42
let scriptModule : ModuleNode | undefined
43
- if ( descriptor . script ?. lang && ! descriptor . script . src ) {
43
+ if (
44
+ ( descriptor . scriptSetup ?. lang && ! descriptor . scriptSetup . src ) ||
45
+ ( descriptor . script ?. lang && ! descriptor . script . src )
46
+ ) {
44
47
const scriptModuleRE = new RegExp (
45
- `type=script.*&lang\.${ descriptor . script . lang } $`
48
+ `type=script.*&lang\.${
49
+ descriptor . scriptSetup ?. lang || descriptor . script ?. lang
50
+ } $`
46
51
)
47
52
scriptModule = modules . find ( ( m ) => scriptModuleRE . test ( m . url ) )
48
53
}
You can’t perform that action at this time.
0 commit comments