@@ -2129,6 +2129,9 @@ function vitePluginRscCss(
21292129 const importer = parsed . id
21302130 if ( this . environment . mode === 'dev' ) {
21312131 const result = collectCss ( server . environments . rsc ! , importer )
2132+ for ( const file of [ importer , ...result . visitedFiles ] ) {
2133+ this . addWatchFile ( file )
2134+ }
21322135 const cssHrefs = result . hrefs . map ( ( href ) => href . slice ( 1 ) )
21332136 const deps = assetsURLOfDeps ( { css : cssHrefs , js : [ ] } , manager )
21342137 return generateResourcesCode (
@@ -2150,20 +2153,6 @@ function vitePluginRscCss(
21502153 }
21512154 }
21522155 } ,
2153- hotUpdate ( ctx ) {
2154- if ( this . environment . name === 'rsc' ) {
2155- const { server } = manager
2156- const mods = collectModuleDependents ( ctx . modules )
2157- for ( const mod of mods ) {
2158- if ( mod . id ) {
2159- invalidteModuleById (
2160- server . environments . rsc ! ,
2161- `\0` + toCssVirtual ( { id : mod . id , type : 'rsc' } ) ,
2162- )
2163- }
2164- }
2165- }
2166- } ,
21672156 } ,
21682157 createVirtualPlugin (
21692158 'vite-rsc/remove-duplicate-server-css' ,
@@ -2198,29 +2187,6 @@ export default function RemoveDuplicateServerCss() {
21982187 ]
21992188}
22002189
2201- function invalidteModuleById ( environment : DevEnvironment , id : string ) {
2202- const mod = environment . moduleGraph . getModuleById ( id )
2203- if ( mod ) {
2204- environment . moduleGraph . invalidateModule ( mod )
2205- }
2206- return mod
2207- }
2208-
2209- function collectModuleDependents ( mods : EnvironmentModuleNode [ ] ) {
2210- const visited = new Set < EnvironmentModuleNode > ( )
2211- function recurse ( mod : EnvironmentModuleNode ) {
2212- if ( visited . has ( mod ) ) return
2213- visited . add ( mod )
2214- for ( const importer of mod . importers ) {
2215- recurse ( importer )
2216- }
2217- }
2218- for ( const mod of mods ) {
2219- recurse ( mod )
2220- }
2221- return [ ...visited ]
2222- }
2223-
22242190function generateResourcesCode ( depsCode : string , manager : RscPluginManager ) {
22252191 const ResourcesFn = (
22262192 React : typeof import ( 'react' ) ,
0 commit comments