Skip to content

Commit

Permalink
fix(optimizer): only run require-import convertion if it was called b…
Browse files Browse the repository at this point in the history
…y require
  • Loading branch information
sapphi-red committed Jun 26, 2022
1 parent 2c2a86b commit e8f8d30
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/vite/src/node/optimizer/esbuildDepPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,16 @@ export function esbuildDepPlugin(

const resolved = await resolve(id, importer, kind)
if (resolved) {
// here it is not set to `external: true` to convert `require` to `import`
if (kind === 'require-call') {
// here it is not set to `external: true` to convert `require` to `import`
return {
path: resolved,
namespace: externalWithConversionNamespace
}
}
return {
path: resolved,
namespace: externalWithConversionNamespace
external: true
}
}
}
Expand Down

0 comments on commit e8f8d30

Please sign in to comment.