natemoo-re / astro-icon

Inline and sprite-based SVGs in Astro made easy!
https://astroicon.dev
Other
995 stars 57 forks source link

Astro v2.4.5 breaks use of local icons when Astro assets enabled #95

Closed paulrudy closed 1 year ago

paulrudy commented 1 year ago

I'm using Astro in SSR mode with the Vercel adapter. After upgrading from Astro v2.4.4 to v2.4.5, I get the following error:

Error: [astro-icon] Unable to load "/src/icons/logo.svg". Does the file exist?
    at Module.load [as default] (/node_modules/.pnpm/astro-icon@0.8.0/node_modules/astro-icon/lib/utils.ts:186:13)
    at eval (/node_modules/.pnpm/astro-icon@0.8.0/node_modules/astro-icon/lib/Icon.astro:22:52)
    at AstroComponentInstance.Icon [as factory] (/node_modules/.pnpm/astro@2.4.5_sass@1.62.1_sharp@0.32.1/node_modules/astro/dist/runtime/server/astro-component.js:22:12)
    at AstroComponentInstance.init (/node_modules/.pnpm/astro@2.4.5_sass@1.62.1_sharp@0.32.1/node_modules/astro/dist/runtime/server/render/astro/instance.js:28:29)
    at AstroComponentInstance.render (/node_modules/.pnpm/astro@2.4.5_sass@1.62.1_sharp@0.32.1/node_modules/astro/dist/runtime/server/render/astro/instance.js:33:18)
    at render.next (<anonymous>)
    at Module.renderChild (/node_modules/.pnpm/astro@2.4.5_sass@1.62.1_sharp@0.32.1/node_modules/astro/dist/runtime/server/render/any.js:30:18)
    at async [Symbol.asyncIterator] (/node_modules/.pnpm/astro@2.4.5_sass@1.62.1_sharp@0.32.1/node_modules/astro/dist/runtime/server/render/astro/render-template.js:34:7)
    at async Module.renderAstroTemplateResult (/node_modules/.pnpm/astro@2.4.5_sass@1.62.1_sharp@0.32.1/node_modules/astro/dist/runtime/server/render/astro/render-template.js:42:20)
    at async Module.renderChild (/node_modules/.pnpm/astro@2.4.5_sass@1.62.1_sharp@0.32.1/node_modules/astro/dist/runtime/server/render/any.js:28:5)

Adding "svgo": "2.8.0" to devDependencies as suggested here didn't help.

Both of the commits in Astro v2.4.5 relate to paths.

paulrudy commented 1 year ago

Updated the title of the issue: This issue only relates to local icons, and it seems to have to do with Astro assets (so perhaps this commit from v 2.4.5. When I disabled the experimental assets feature, this issue was resolved. It would be nice to be able to continue to use Astro assets, however.

stramel commented 1 year ago

I'll try to take a look tonight because I was just using it. I might be on 2.4.4 though

stramel commented 1 year ago

Can confirm after upgrading to 2.4.5, it is broken. Looking into a fix

stramel commented 1 year ago

Appears to be an upstream issue. Filed a upstream bug: https://github.com/withastro/astro/issues/7082

paulrudy commented 1 year ago

Appears to be an upstream issue. Filed a upstream bug: https://github.com/withastro/astro/issues/7082

Sweet, thank you for looking into it!

paulrudy commented 1 year ago

Are you using "experimental: { assets: true }" in the astro.config.mjs file? If so...remove it.

This issue is meant to report specifically that there is a conflict between the experimental assets and astro-icon since Astro v2.4.5. Removing the use of the experimental assets would certainly be a way not to encounter this issue. So would uninstalling astro-icon.

I'm interested in them both playing nicely together again.

paulrudy commented 1 year ago

Fixed with Astro v2.5.0!