Skip to content

Commit

Permalink
fix: the result value of resolve add a namespace when processing a '@…
Browse files Browse the repository at this point in the history
…' in filter,fix vitejs#3532
  • Loading branch information
ygj6 committed May 25, 2021
1 parent 496e26e commit c94c486
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/vite/src/node/optimizer/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ const htmlTypesRE = /\.(html|vue|svelte)$/
// use Acorn because it's slow. Luckily this doesn't have to be bullet proof
// since even missed imports can be caught at runtime, and false positives will
// simply be ignored.
const importsRE =
/\bimport(?!\s+type)(?:[\w*{}\n\r\t, ]+from\s*)?\s*("[^"]+"|'[^']+')/gm
const importsRE = /\bimport(?!\s+type)(?:[\w*{}\n\r\t, ]+from\s*)?\s*("[^"]+"|'[^']+')/gm

export async function scanImports(config: ResolvedConfig): Promise<{
export async function scanImports(
config: ResolvedConfig
): Promise<{
deps: Record<string, string>
missing: Record<string, string>
}> {
Expand Down Expand Up @@ -125,8 +126,7 @@ function globEntries(pattern: string | string[], config: ResolvedConfig) {
})
}

const scriptModuleRE =
/(<script\b[^>]*type\s*=\s*(?:"module"|'module')[^>]*>)(.*?)<\/script>/gims
const scriptModuleRE = /(<script\b[^>]*type\s*=\s*(?:"module"|'module')[^>]*>)(.*?)<\/script>/gims
export const scriptRE = /(<script\b(\s[^>]*>|>))(.*?)<\/script>/gims
export const commentRE = /<!--(.|[\r\n])*?-->/
const srcRE = /\bsrc\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im
Expand Down Expand Up @@ -288,9 +288,12 @@ function esbuildScanPlugin(
}
return externalUnlessEntry({ path: id })
} else {
const namespace = htmlTypesRE.test(resolved) ? 'html' : undefined

// linked package, keep crawling
return {
path: path.resolve(resolved)
path: path.resolve(resolved),
namespace
}
}
} else {
Expand Down

0 comments on commit c94c486

Please sign in to comment.