Skip to content

Commit

Permalink
fix: chunks are analysed multiple times (vitejs#2541)
Browse files Browse the repository at this point in the history
Co-authored-by: Richard Petersen <[email protected]>
  • Loading branch information
Richard Petersen and Richard Petersen authored Apr 4, 2021
1 parent b4a1526 commit 1451b78
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/vite/src/node/plugins/importAnalysisBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {

if (imports.length) {
const s = new MagicString(code)
const analyzed: Set<string> = new Set<string>()
for (let index = 0; index < imports.length; index++) {
const { s: start, e: end, d: dynamicIndex } = imports[index]
// if dynamic import polyfill is used, rewrite the import to
Expand All @@ -234,6 +235,8 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
// literal import - trace direct imports and add to deps
const addDeps = (filename: string) => {
if (filename === ownerFilename) return
if (analyzed.has(filename)) return
analyzed.add(filename)
const chunk = bundle[filename] as OutputChunk | undefined
if (chunk) {
deps.add(config.base + chunk.fileName)
Expand Down

0 comments on commit 1451b78

Please sign in to comment.