Skip to content

Commit 47197fb

Browse files
Jungzlantfu
andauthoredJul 23, 2024
fix: should only filter installed packages for optimization (#517)
Co-authored-by: Anthony Fu <github@antfu.me>
1 parent 6868e9c commit 47197fb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎src/core/unplugin.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isPackageExists } from 'local-pkg'
12
import { minimatch } from 'minimatch'
23
import { slash } from '@antfu/utils'
34
import { createUnplugin } from 'unplugin'
@@ -29,7 +30,7 @@ export default createUnplugin<Options>((options) => {
2930
const exclude = config.optimizeDeps?.exclude || []
3031

3132
const imports = new Set((await ctx.unimport.getImports()).map(i => i.from)
32-
.filter(i => i.match(/^[a-z@]/) && !exclude.includes(i)))
33+
.filter(i => i.match(/^[a-z@]/) && !exclude.includes(i) && isPackageExists(i)))
3334

3435
if (!imports.size)
3536
return

0 commit comments

Comments
 (0)