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({
551
551
file : "styles-bundled.css" ,
552
552
selector : "#css-bundled" ,
553
553
} ,
554
+ {
555
+ file : "styles.module.css" ,
556
+ selector : "#css-modules" ,
557
+ } ,
554
558
{
555
559
file : "styles-postcss-linked.css" ,
556
560
selector : "#css-postcss-linked" ,
@@ -564,10 +568,6 @@ async function hmrWorkflow({
564
568
...( routeBase === "rsc-server-first-route"
565
569
? [ ]
566
570
: ( [
567
- {
568
- file : "styles.module.css" ,
569
- selector : "#css-modules" ,
570
- } ,
571
571
{
572
572
file : "styles-vanilla-local.css.ts" ,
573
573
selector : "#css-vanilla-local" ,
Original file line number Diff line number Diff line change @@ -280,9 +280,19 @@ export function reactRouterRSCVitePlugin(): Vite.PluginOption[] {
280
280
async hotUpdate ( this , { server, file, modules } ) {
281
281
if ( this . environment . name !== "rsc" ) return ;
282
282
283
+ const clientModules =
284
+ server . environments . client . moduleGraph . getModulesByFile ( file ) ;
285
+
286
+ const vite = await import ( "vite" ) ;
283
287
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
+ ) ) ;
286
296
287
297
for ( const mod of getModulesWithImporters ( modules ) ) {
288
298
if ( ! mod . file ) continue ;
You can’t perform that action at this time.
0 commit comments