Skip to content

Commit 1451b78

Browse files
Richard PetersenRichard Petersen
Richard Petersen
and
Richard Petersen
authored
fix: chunks are analysed multiple times (#2541)
Co-authored-by: Richard Petersen <[email protected]>
1 parent b4a1526 commit 1451b78

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

packages/vite/src/node/plugins/importAnalysisBuild.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
218218

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

0 commit comments

Comments
 (0)