Skip to content

Commit ce1da35

Browse files
committed
fix: check /node_modules/ instead of ?v=
1 parent d6f85c2 commit ce1da35

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/plugin-rsc/src/plugin.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -963,9 +963,9 @@ function vitePluginUseClient(
963963
let importId: string
964964
let referenceKey: string
965965
const packageSource = packageSources.get(id)
966-
if (!packageSource && id.includes('?v=')) {
966+
if (!packageSource && id.includes('/node_modules/')) {
967967
assert(this.environment.mode === 'dev')
968-
// If non package source `?v=<hash>` reached here, this is a client boundary
968+
// If non package source reached here (often with ?v=... query), this is a client boundary
969969
// created by a package imported on server environment, which breaks the
970970
// expectation on dependency optimizer on browser. Directly copying over
971971
// "?v=<hash>" from client optimizer in client reference can make a hashed
@@ -1225,7 +1225,7 @@ function vitePluginUseServer(
12251225
let normalizedId_: string | undefined
12261226
const getNormalizedId = () => {
12271227
if (!normalizedId_) {
1228-
if (id.includes('?v=')) {
1228+
if (id.includes('/node_modules/')) {
12291229
assert(this.environment.mode === 'dev')
12301230
const ignored =
12311231
useServerPluginOptions.ignoredPackageWarnings?.some(
@@ -1240,8 +1240,8 @@ function vitePluginUseServer(
12401240
)
12411241
}
12421242
// module runner has additional resolution step and it's not strict about
1243-
// module identity of `import(id)` like browser, so we simply strip it off.
1244-
id = id.split('?v=')[0]!
1243+
// module identity of `import(id)` like browser, so we simply strip queries such as `?v=`.
1244+
id = cleanUrl(id)
12451245
}
12461246
if (config.command === 'build') {
12471247
normalizedId_ = hashString(path.relative(config.root, id))

0 commit comments

Comments
 (0)