Skip to content

Commit 129d0d0

Browse files
authored
fix(scanner): catch all external files for glob imports (#15286)
1 parent b1a6c84 commit 129d0d0

File tree

1 file changed

+10
-11
lines changed
  • packages/vite/src/node/optimizer

1 file changed

+10
-11
lines changed

packages/vite/src/node/optimizer/scan.ts

+10-11
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,6 @@ function esbuildScanPlugin(
550550
// should be faster than doing it in the catch-all via js
551551
// they are done after the bare import resolve because a package name
552552
// may end with these extensions
553-
554553
const setupExternalize = (
555554
filter: RegExp,
556555
doExternalize: (path: string) => boolean,
@@ -561,16 +560,6 @@ function esbuildScanPlugin(
561560
external: doExternalize(path),
562561
}
563562
})
564-
// onResolve is not called for glob imports.
565-
// we need to add that here as well until esbuild calls onResolve for glob imports.
566-
// https://github.com/evanw/esbuild/issues/3317
567-
build.onLoad({ filter, namespace: 'file' }, () => {
568-
const externalOnLoadResult: OnLoadResult = {
569-
loader: 'js',
570-
contents: 'export default {}',
571-
}
572-
return externalOnLoadResult
573-
})
574563
}
575564

576565
// css
@@ -647,6 +636,16 @@ function esbuildScanPlugin(
647636
contents,
648637
}
649638
})
639+
640+
// onResolve is not called for glob imports.
641+
// we need to add that here as well until esbuild calls onResolve for glob imports.
642+
// https://github.com/evanw/esbuild/issues/3317
643+
build.onLoad({ filter: /.*/, namespace: 'file' }, () => {
644+
return {
645+
loader: 'js',
646+
contents: 'export default {}',
647+
}
648+
})
650649
},
651650
}
652651
}

0 commit comments

Comments
 (0)