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: chunks are analysed multiple times #2541

Merged
merged 1 commit into from Apr 4, 2021
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
3 changes: 3 additions & 0 deletions packages/vite/src/node/plugins/importAnalysisBuild.ts
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