@@ -34,6 +34,7 @@ import { generateEncryptionKey, toBase64 } from './utils/encryption-utils'
3434import { createRpcServer } from './utils/rpc'
3535import {
3636 cleanUrl ,
37+ directRequestRE ,
3738 evalValue ,
3839 normalizeViteImportAnalysisUrl ,
3940 prepareError ,
@@ -563,11 +564,7 @@ export default function vitePluginRsc(
563564 async hotUpdate ( ctx ) {
564565 if ( isCSSRequest ( ctx . file ) ) {
565566 if ( this . environment . name === 'client' ) {
566- // filter out `.css?direct` (injected by SSR) to avoid browser full reload
567- // when changing non-self accepting css such as `module.css`.
568- return ctx . modules . filter (
569- ( m ) => ! ( m . id ?. includes ( '?direct' ) && ! m . isSelfAccepting ) ,
570- )
567+ return
571568 }
572569 }
573570
@@ -1976,6 +1973,29 @@ function vitePluginRscCss(
19761973 }
19771974 } ,
19781975 } ,
1976+ {
1977+ // force self accepting "?direct" css (injected via SSR `<link />`) to avoid full reload.
1978+ // this should only apply to css modules
1979+ // https://github.com/vitejs/vite/blob/84079a84ad94de4c1ef4f1bdb2ab448ff2c01196/packages/vite/src/node/plugins/css.ts#L1096
1980+ name : 'rsc:rsc-css-self-accept' ,
1981+ apply : 'serve' ,
1982+ transform : {
1983+ order : 'post' ,
1984+ handler ( _code , id , _options ) {
1985+ if (
1986+ this . environment . name === 'client' &&
1987+ this . environment . mode === 'dev' &&
1988+ isCSSRequest ( id ) &&
1989+ directRequestRE . test ( id )
1990+ ) {
1991+ const mod = this . environment . moduleGraph . getModuleById ( id )
1992+ if ( mod && ! mod . isSelfAccepting ) {
1993+ mod . isSelfAccepting = true
1994+ }
1995+ }
1996+ } ,
1997+ } ,
1998+ } ,
19791999 {
19802000 name : 'rsc:css-virtual' ,
19812001 resolveId ( source ) {
0 commit comments