File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed
packages/react-router-dev/vite/rsc Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -551,6 +551,10 @@ async function hmrWorkflow({
551551 file : "styles-bundled.css" ,
552552 selector : "#css-bundled" ,
553553 } ,
554+ {
555+ file : "styles.module.css" ,
556+ selector : "#css-modules" ,
557+ } ,
554558 {
555559 file : "styles-postcss-linked.css" ,
556560 selector : "#css-postcss-linked" ,
@@ -564,10 +568,6 @@ async function hmrWorkflow({
564568 ...( routeBase === "rsc-server-first-route"
565569 ? [ ]
566570 : ( [
567- {
568- file : "styles.module.css" ,
569- selector : "#css-modules" ,
570- } ,
571571 {
572572 file : "styles-vanilla-local.css.ts" ,
573573 selector : "#css-vanilla-local" ,
Original file line number Diff line number Diff line change @@ -280,9 +280,19 @@ export function reactRouterRSCVitePlugin(): Vite.PluginOption[] {
280280 async hotUpdate ( this , { server, file, modules } ) {
281281 if ( this . environment . name !== "rsc" ) return ;
282282
283+ const clientModules =
284+ server . environments . client . moduleGraph . getModulesByFile ( file ) ;
285+
286+ const vite = await import ( "vite" ) ;
283287 const isServerOnlyChange =
284- ( server . environments . client . moduleGraph . getModulesByFile ( file )
285- ?. size ?? 0 ) === 0 ;
288+ ! clientModules ||
289+ clientModules . size === 0 ||
290+ // Handle CSS injected from server-first routes (with ?direct query
291+ // string) since the client graph has a reference to the CSS
292+ ( vite . isCSSRequest ( file ) &&
293+ Array . from ( clientModules ) . some ( ( mod ) =>
294+ mod . id ?. includes ( "?direct" ) ,
295+ ) ) ;
286296
287297 for ( const mod of getModulesWithImporters ( modules ) ) {
288298 if ( ! mod . file ) continue ;
You can’t perform that action at this time.
0 commit comments