@@ -34,6 +34,7 @@ import { generateEncryptionKey, toBase64 } from './utils/encryption-utils'
34
34
import { createRpcServer } from './utils/rpc'
35
35
import {
36
36
cleanUrl ,
37
+ directRequestRE ,
37
38
evalValue ,
38
39
normalizeViteImportAnalysisUrl ,
39
40
prepareError ,
@@ -563,11 +564,7 @@ export default function vitePluginRsc(
563
564
async hotUpdate ( ctx ) {
564
565
if ( isCSSRequest ( ctx . file ) ) {
565
566
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
571
568
}
572
569
}
573
570
@@ -1976,6 +1973,29 @@ function vitePluginRscCss(
1976
1973
}
1977
1974
} ,
1978
1975
} ,
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
+ } ,
1979
1999
{
1980
2000
name : 'rsc:css-virtual' ,
1981
2001
resolveId ( source ) {
0 commit comments