From 47197fb6959534b395d796281224844b00bc1227 Mon Sep 17 00:00:00 2001 From: Jungzl <13jungzl@gmail.com> Date: Tue, 23 Jul 2024 19:40:31 +0800 Subject: [PATCH] fix: should only filter installed packages for optimization (#517) Co-authored-by: Anthony Fu --- src/core/unplugin.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/unplugin.ts b/src/core/unplugin.ts index d3f37d0a..3f59fcc4 100644 --- a/src/core/unplugin.ts +++ b/src/core/unplugin.ts @@ -1,3 +1,4 @@ +import { isPackageExists } from 'local-pkg' import { minimatch } from 'minimatch' import { slash } from '@antfu/utils' import { createUnplugin } from 'unplugin' @@ -29,7 +30,7 @@ export default createUnplugin((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