Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use isOptimizable to ensure version query #10141

Merged
merged 1 commit into from Sep 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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