File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
examples/basic/src/routes/style-server Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,6 @@ export function TestStyleServer() {
28
28
)
29
29
}
30
30
31
- // add no-op `import.meta.hot` to trigger `prune` event
32
- // https://github.com/vitejs/vite/blob/84079a84ad94de4c1ef4f1bdb2ab448ff2c01196/packages/vite/src/node/plugins/importAnalysis.ts#L829-L840
31
+ // add no-op `import.meta.hot` to trigger `prune` event.
32
+ // this is needed until we land https://github.com/vitejs/vite/pull/20768
33
33
import . meta. hot
Original file line number Diff line number Diff line change @@ -1026,6 +1026,11 @@ import.meta.hot.on("rsc:update", () => {
1026
1026
document.querySelectorAll("vite-error-overlay").forEach((n) => n.close())
1027
1027
});
1028
1028
`
1029
+ // remove stylesheet links when css import is removed on rsc envrionment
1030
+ const onRscPrune = ( e : vite . PrunePayload ) => {
1031
+ console . log ( '[rsc:prune]' , e )
1032
+ }
1033
+ code += `import.meta.hot.on("rsc:prune", ${ onRscPrune } );`
1029
1034
return code
1030
1035
} ,
1031
1036
) ,
@@ -2036,7 +2041,11 @@ function vitePluginRscCss(
2036
2041
hot . send = function ( this , ...args : any [ ] ) {
2037
2042
const e = args [ 0 ] as vite . PrunePayload
2038
2043
if ( e && typeof e === 'object' && e . type === 'prune' ) {
2039
- console . log ( '[rsc:prune]' , e )
2044
+ server . environments . client . hot . send ( {
2045
+ type : 'custom' ,
2046
+ event : 'rsc:prune' ,
2047
+ data : e ,
2048
+ } )
2040
2049
}
2041
2050
return original . apply ( this , args as any )
2042
2051
}
You can’t perform that action at this time.
0 commit comments