Skip to content

Commit

Permalink
Merge pull request #14 from FXHDHR/fix/catch
Browse files Browse the repository at this point in the history
fix: error when dependency hasn't been installed
  • Loading branch information
sanyuan0704 authored Nov 21, 2022
2 parents 591abd9 + 058db58 commit 0f44fd9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
8 changes: 1 addition & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
29 changes: 16 additions & 13 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
}
}

0 comments on commit 0f44fd9

Please sign in to comment.