Skip to content

Commit 139a653

Browse files
committed
fix: wip
1 parent bf94a13 commit 139a653

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export function clientDep() {
2-
return '[ok-edit]'
2+
return '[ok]'
33
}

packages/plugin-rsc/examples/basic/vite.config.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@ import { fileURLToPath } from 'node:url'
1717
export default defineConfig({
1818
clearScreen: false,
1919
plugins: [
20+
// TODO: generalize
21+
{
22+
name: 'poc',
23+
async hotUpdate(ctx) {
24+
// when client only dependencies is changed,
25+
// need to invalidate the corresponding route's original server module.
26+
if (ctx.file.includes('/hmr-client-dep2/client-dep.ts')) {
27+
if (this.environment.name === 'rsc') {
28+
const routeFile = path.join(ctx.file, '../client.tsx')
29+
const mods =
30+
this.environment.moduleGraph.getModulesByFile(routeFile)
31+
for (const mod of mods ?? []) {
32+
this.environment.moduleGraph.invalidateModule(mod)
33+
}
34+
}
35+
}
36+
},
37+
},
2038
// inspect(),
2139
tailwindcss(),
2240
react(),

0 commit comments

Comments
 (0)