File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed
examples/basic/src/routes/hmr-switch Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import React from 'react'
55export function TestHmrSwitchClient ( ) {
66 return (
77 < div data-testid = "test-hmr-switch-client" >
8- test-hmr-foo- switch-clietn (useState: { String ( ! ! React . useState ) } )
8+ test-hmr-switch-client (useState: { String ( ! ! React . useState ) } )
99 </ div >
1010 )
1111}
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import React from 'react'
33export function TestHmrSwitchServer ( ) {
44 return (
55 < div data-testid = "test-hmr-switch-server" >
6- test-hmr-foo- switch-server (useState: { String ( ! ! React . useState ) } )
6+ test-hmr-switch-server (useState: { String ( ! ! React . useState ) } )
77 </ div >
88 )
99}
Original file line number Diff line number Diff line change @@ -453,6 +453,7 @@ export default function vitePluginRsc(
453453 const ids = ctx . modules . map ( ( mod ) => mod . id ) . filter ( ( v ) => v !== null )
454454 if ( ids . length === 0 ) return
455455
456+ // TODO: handle server<->client switch
456457 // a shared component/module will have `isInsideClientBoundary = false` on `rsc` environment
457458 // and `isInsideClientBoundary = true` on `client` environment,
458459 // which means both server hmr and client hmr will be triggered.
@@ -1009,10 +1010,16 @@ function vitePluginUseClient(
10091010 name : 'rsc:use-client' ,
10101011 async transform ( code , id ) {
10111012 if ( this . environment . name !== serverEnvironmentName ) return
1012- if ( ! code . includes ( 'use client' ) ) return
1013+ if ( ! code . includes ( 'use client' ) ) {
1014+ delete manager . clientReferenceMetaMap [ id ]
1015+ return
1016+ }
10131017
10141018 const ast = await parseAstAsync ( code )
1015- if ( ! hasDirective ( ast . body , 'use client' ) ) return
1019+ if ( ! hasDirective ( ast . body , 'use client' ) ) {
1020+ delete manager . clientReferenceMetaMap [ id ]
1021+ return
1022+ }
10161023
10171024 let importId : string
10181025 let referenceKey : string
@@ -1083,7 +1090,6 @@ function vitePluginUseClient(
10831090 } )
10841091 if ( ! result ) return
10851092 const { output, exportNames } = result
1086- // TODO
10871093 manager . clientReferenceMetaMap [ id ] = {
10881094 importId,
10891095 referenceKey,
You can’t perform that action at this time.
0 commit comments