Skip to content

Commit

Permalink
fix(scan): skip non-absolute resolved paths during scan
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 31, 2021
1 parent febff7b commit f635971
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions packages/vite/src/node/optimizer/scan.ts
Expand Up @@ -11,11 +11,8 @@ import {
isObject,
cleanUrl,
externalRE,
dataUrlRE,
isExternalUrl,
isDataUrl
dataUrlRE
} from '../utils'
import { browserExternalId } from '../plugins/resolve'
import {
createPluginContainer,
PluginContainer
Expand Down Expand Up @@ -345,20 +342,16 @@ async function transformGlob(source: string, importer: string) {
}

export function shouldExternalizeDep(resolvedId: string, rawId?: string) {
// virtual id
if (resolvedId === rawId || resolvedId.includes('\0')) {
// not a valid file path
if (!path.isAbsolute(resolvedId)) {
return true
}
// browser external
if (resolvedId.startsWith(browserExternalId)) {
// virtual id
if (resolvedId === rawId || resolvedId.includes('\0')) {
return true
}
// resovled is not a js type
if (!jsTypesRE.test(resolvedId)) {
return true
}
// external or data url
if (isExternalUrl(resolvedId) || isDataUrl(resolvedId)) {
return true
}
}

0 comments on commit f635971

Please sign in to comment.