Skip to content

Commit 394529a

Browse files
committed
refactor: tweak
1 parent 8992a2f commit 394529a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/plugin-rsc/src/plugin.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { generateEncryptionKey, toBase64 } from './utils/encryption-utils'
3434
import { createRpcServer } from './utils/rpc'
3535
import {
3636
cleanUrl,
37+
directRequestRE,
3738
evalValue,
3839
normalizeViteImportAnalysisUrl,
3940
prepareError,
@@ -1984,11 +1985,11 @@ function vitePluginRscCss(
19841985
if (
19851986
this.environment.name === 'client' &&
19861987
this.environment.mode === 'dev' &&
1987-
isCSSRequest(id)
1988+
isCSSRequest(id) &&
1989+
directRequestRE.test(id)
19881990
) {
19891991
const mod = this.environment.moduleGraph.getModuleById(id)
1990-
const parsed = parseIdQuery(id)
1991-
if (mod && !mod.isSelfAccepting && 'direct' in parsed.query) {
1992+
if (mod && !mod.isSelfAccepting) {
19921993
mod.isSelfAccepting = true
19931994
}
19941995
}

packages/plugin-rsc/src/plugins/vite-utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,6 @@ export function evalValue<T = any>(rawValue: string): T {
161161
`)
162162
return fn()
163163
}
164+
165+
// https://github.com/vitejs/vite/blob/84079a84ad94de4c1ef4f1bdb2ab448ff2c01196/packages/vite/src/node/utils.ts#L321
166+
export const directRequestRE: RegExp = /(\?|&)direct=?(?:&|$)/

0 commit comments

Comments
 (0)