Skip to content

Commit 00327c8

Browse files
committed
wip
1 parent 7f5243f commit 00327c8

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

packages/plugin-rsc/examples/basic/src/routes/style-server/server.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ export function TestStyleServer() {
2828
)
2929
}
3030

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
3333
import.meta.hot

packages/plugin-rsc/src/plugin.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,11 @@ import.meta.hot.on("rsc:update", () => {
10261026
document.querySelectorAll("vite-error-overlay").forEach((n) => n.close())
10271027
});
10281028
`
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});`
10291034
return code
10301035
},
10311036
),
@@ -2036,7 +2041,11 @@ function vitePluginRscCss(
20362041
hot.send = function (this, ...args: any[]) {
20372042
const e = args[0] as vite.PrunePayload
20382043
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+
})
20402049
}
20412050
return original.apply(this, args as any)
20422051
}

0 commit comments

Comments
 (0)