Skip to content

Commit

Permalink
fix: should only filter installed packages for optimization (#517)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <[email protected]>
  • Loading branch information
Jungzl and antfu authored Jul 23, 2024
1 parent 6868e9c commit 47197fb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/unplugin.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isPackageExists } from 'local-pkg'
import { minimatch } from 'minimatch'
import { slash } from '@antfu/utils'
import { createUnplugin } from 'unplugin'
Expand Down Expand Up @@ -29,7 +30,7 @@ export default createUnplugin<Options>((options) => {
const exclude = config.optimizeDeps?.exclude || []

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

if (!imports.size)
return
Expand Down

0 comments on commit 47197fb

Please sign in to comment.