Skip to content

Commit

Permalink
fix(createIconPack): handle unresolved modules (#148)
Browse files Browse the repository at this point in the history
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
  • Loading branch information
kripod and natemoo-re committed Dec 5, 2023
1 parent 832ac05 commit d176a7d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/great-carpets-hide.md
@@ -0,0 +1,5 @@
---
"astro-icon": patch
---

Fixes an edge case with `createIconPack` when a module cannot be resolved
9 changes: 8 additions & 1 deletion packages/core/lib/createIconPack.ts
Expand Up @@ -15,7 +15,14 @@ export function createIconPack({
}: CreateIconPackOptions) {
if (pkg) {
return async (name: string) => {
const baseUrl = new URL(pathToFileURL(resolvePackage(pkg)) + "/");
const pkgPath = resolvePackage(pkg);
if (!pkgPath) {
throw new Error(
`[astro-icon] Unable to resolve "${pkgPath}"! Is the package installed?"`
);
}

const baseUrl = new URL(pathToFileURL(pkgPath) + "/");
const path = fileURLToPath(
new URL(dir ? `${dir}/${name}.svg` : `${name}.svg`, baseUrl)
);
Expand Down

1 comment on commit d176a7d

@vercel
Copy link

@vercel vercel bot commented on d176a7d Dec 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

api-astroicon – ./packages/service

api-astroicon-nmoo.vercel.app
api-astroicon-git-main-nmoo.vercel.app
api.astroicon.dev

Please sign in to comment.