Skip to content

Commit

Permalink
fix(optimizer): only run require-import conversion if require'd (#8795)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Jun 26, 2022
1 parent 8de4319 commit 7ae0d3e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/vite/src/node/optimizer/esbuildDepPlugin.ts
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 7ae0d3e

Please sign in to comment.