Skip to content

Commit

Permalink
refactor(vite): refactor optimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-He95 committed Jun 23, 2024
1 parent ec16a5e commit a503d79
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 a503d79

Please sign in to comment.