Skip to content

Commit

Permalink
refactor(optimizer): use early continues (#17551)
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-He95 authored Jun 23, 2024
1 parent ff57d61 commit 7c06ef0
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions packages/vite/src/node/optimizer/optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -790,17 +790,16 @@ function findInteropMismatches(
const needsInteropMismatch = []
for (const dep in discovered) {
const discoveredDepInfo = discovered[dep]
if (discoveredDepInfo.needsInterop === undefined) continue

const depInfo = optimized[dep]
if (depInfo) {
if (
discoveredDepInfo.needsInterop !== undefined &&
depInfo.needsInterop !== discoveredDepInfo.needsInterop
) {
// This only happens when a discovered dependency has mixed ESM and CJS syntax
// and it hasn't been manually added to optimizeDeps.needsInterop
needsInteropMismatch.push(dep)
debug?.(colors.cyan(`✨ needsInterop mismatch detected for ${dep}`))
}
if (!depInfo) continue

if (depInfo.needsInterop !== discoveredDepInfo.needsInterop) {
// This only happens when a discovered dependency has mixed ESM and CJS syntax
// and it hasn't been manually added to optimizeDeps.needsInterop
needsInteropMismatch.push(dep)
debug?.(colors.cyan(`✨ needsInterop mismatch detected for ${dep}`))
}
}
return needsInteropMismatch
Expand Down

0 comments on commit 7c06ef0

Please sign in to comment.