Skip to content

Commit

Permalink
fix: use isOptimizable to ensure version query (#10141)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Sep 16, 2022
1 parent d324181 commit 23a51c6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/vite/src/node/plugins/resolve.ts
Expand Up @@ -29,6 +29,7 @@ import {
isFileReadable,
isNonDriveRelativeAbsolutePath,
isObject,
isOptimizable,
isPossibleTsOutput,
isTsRequest,
isWindows,
Expand Down Expand Up @@ -181,7 +182,7 @@ export function resolvePlugin(resolveOptions: InternalResolveOptions): Plugin {

if (isNodeModule && !resolved.match(DEP_VERSION_RE)) {
const versionHash = depsOptimizer.metadata.browserHash
if (versionHash && OPTIMIZABLE_ENTRY_RE.test(resolved)) {
if (versionHash && isOptimizable(resolved, depsOptimizer.options)) {
resolved = injectQuery(resolved, `v=${versionHash}`)
}
}
Expand Down Expand Up @@ -750,7 +751,9 @@ export function tryNodeResolve(
}

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

let exclude = depsOptimizer?.options.exclude
let include = depsOptimizer?.options.exclude
Expand Down

0 comments on commit 23a51c6

Please sign in to comment.