Skip to content

Commit 23a51c6

Browse files
authored
fix: use isOptimizable to ensure version query (#10141)
1 parent d324181 commit 23a51c6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/vite/src/node/plugins/resolve.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
isFileReadable,
3030
isNonDriveRelativeAbsolutePath,
3131
isObject,
32+
isOptimizable,
3233
isPossibleTsOutput,
3334
isTsRequest,
3435
isWindows,
@@ -181,7 +182,7 @@ export function resolvePlugin(resolveOptions: InternalResolveOptions): Plugin {
181182

182183
if (isNodeModule && !resolved.match(DEP_VERSION_RE)) {
183184
const versionHash = depsOptimizer.metadata.browserHash
184-
if (versionHash && OPTIMIZABLE_ENTRY_RE.test(resolved)) {
185+
if (versionHash && isOptimizable(resolved, depsOptimizer.options)) {
185186
resolved = injectQuery(resolved, `v=${versionHash}`)
186187
}
187188
}
@@ -750,7 +751,9 @@ export function tryNodeResolve(
750751
}
751752

752753
// if we reach here, it's a valid dep import that hasn't been optimized.
753-
const isJsType = OPTIMIZABLE_ENTRY_RE.test(resolved)
754+
const isJsType = depsOptimizer
755+
? isOptimizable(resolved, depsOptimizer.options)
756+
: OPTIMIZABLE_ENTRY_RE.test(resolved)
754757

755758
let exclude = depsOptimizer?.options.exclude
756759
let include = depsOptimizer?.options.exclude

0 commit comments

Comments
 (0)