Skip to content

Commit

Permalink
fix(optimizer): fix entry cross imports
Browse files Browse the repository at this point in the history
fix #1801
  • Loading branch information
yyx990803 committed Jan 29, 2021
1 parent 328b6b9 commit a9ca3da
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/vite/src/node/optimizer/esbuildDepPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,24 @@ export function esbuildDepPlugin(
async ({ path: id, importer }) => {
// ensure esbuild uses our resolved entires of optimized deps in all
// cases
if (id in qualified) {
const flatId = flattenId(id)
if (flatId in qualified) {
// if is optimized entry, redirect to entry namespace
return {
path: id,
path: flatId,
namespace: 'dep'
}
} else {
// check alias fist
const aliased = await _resolve(id, undefined, true)
if (aliased && bareImportRE.test(aliased)) {
const id = flattenId(aliased)
if (id in qualified) {
const flatId = flattenId(aliased)
if (flatId in qualified) {
// #1780
// id was aliased to a qualified entry, use the entry to
// avoid duplicated copies of the module
return {
path: id,
path: flatId,
namespace: 'dep'
}
}
Expand Down

0 comments on commit a9ca3da

Please sign in to comment.