File tree Expand file tree Collapse file tree
packages/plugin-rsc/examples/basic
src/routes/hmr-client-dep2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11export function clientDep ( ) {
2- return '[ok-edit ]'
2+ return '[ok]'
33}
Original file line number Diff line number Diff line change @@ -17,6 +17,24 @@ import { fileURLToPath } from 'node:url'
1717export 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 ( ) ,
You can’t perform that action at this time.
0 commit comments