natemoo-re / astro-icon

Inline and sprite-based SVGs in Astro made easy!

Home Page:https://astroicon.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: Unable to load the "local" icon set!

adamlevoy opened this issue · comments

commented

What version of astro-icon are you using?

v1.0.1

Astro Info

Astro                    v4.0.9
Node                     v18.16.1
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/tailwind
                         astro-icon

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Getting error below for every instance of local icon when trying to run in local environment on Chrome and Safari. All my icons are local in src/icons. I was unable to reproduce issue via astro.new so I am providing repository. My project heavily uses this integration. Icon instances can be found in files that include:

  • src/sections/Hero_v2
  • src/components/IconCard
  • src/components/MiniReview
  • among others

11:12:48 [ERROR] [UnhandledRejection] Astro detected an unhandled rejection. Here's the stack trace: Error: Unable to load the "local" icon set! at eval (/Users/adam/Code/giddi-pages/node_modules/astro-icon/components/Icon.astro:39:19) at AstroComponentInstance.Icon [as factory] (/Users/adam/Code/giddi-pages/node_modules/astro/dist/runtime/server/astro-component.js:21:12) at AstroComponentInstance.init (/Users/adam/Code/giddi-pages/node_modules/astro/dist/runtime/server/render/astro/instance.js:39:29) at AstroComponentInstance.render (/Users/adam/Code/giddi-pages/node_modules/astro/dist/runtime/server/render/astro/instance.js:44:18) at Object.render (/Users/adam/Code/giddi-pages/node_modules/astro/dist/runtime/server/render/component.js:342:22) at Module.renderChild (/Users/adam/Code/giddi-pages/node_modules/astro/dist/runtime/server/render/any.js:36:17) Hint: Make sure your promises all have an awaitor a.catch() handler. Error reference: https://docs.astro.build/en/reference/errors/unhandled-rejection/ Stack trace: at /Users/adam/Code/giddi-pages/node_modules/astro-icon/components/Icon.astro:48:17 [...] See full stack trace in the browser, or rerun with --verbose.

Screenshot 2024-01-02 at 11 13 44 AM

What's the expected result?

Expect local icons directory to be found and for project to open at localhost.

Link to Minimal Reproducible Example

https://github.com/adamlevoy/giddi-pages

I was able to track this down! It looks like an error is being thrown when loading your icons because the harness.svg contains <text> nodes. That definitely should be supported.

Two things for me to fix:

  1. Ensure that error messages are surfaced
  2. Figure out if the existing importDirectory util can log errors and continue, or, ideally just not error