diff --git a/src/index.ts b/src/index.ts index 207e449..6942175 100644 --- a/src/index.ts +++ b/src/index.ts @@ -29,13 +29,7 @@ const wrapCustomSplitConfig = async ( depsInGroup[group] = await Promise.all( packageInfo .filter((item): boolean => typeof item === "string") - .map((item) => { - try { - return resolveEntry(item as string, root); - } catch (err) { - return ""; - } - }) + .map((item) => resolveEntry(item as string, root)) ); depsInGroup[group] = depsInGroup[group].filter((item) => item.length > 0); } diff --git a/src/utils.ts b/src/utils.ts index 4319d8f..311c3e3 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -20,17 +20,20 @@ export async function resolveEntry( // Vite 3 will expose pure esm package. // Since the api in vite is not stable, we put `vite` in `dependencies` instead of `peerDependencies` and lock the version. await dynamicImport("vite"); - - return resolvePackageEntry( - name, - resolvePackageData(name, root || process.cwd(), true)!, - true, - { - isBuild: true, - isProduction: process.env.NODE_ENV === "production", - isRequire: false, - root: process.cwd(), - preserveSymlinks: false, - } - )!; + try { + return resolvePackageEntry( + name, + resolvePackageData(name, root || process.cwd(), true)!, + true, + { + isBuild: true, + isProduction: process.env.NODE_ENV === "production", + isRequire: false, + root: process.cwd(), + preserveSymlinks: false, + } + )!; + } catch (error) { + return ""; + } }