natemoo-re / astro-icon

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

The library does not work with ssr deno server #52

Closed mrabtikhalid closed 1 year ago

mrabtikhalid commented 1 year ago

Hello This issue is related to #35 I have an astro project with deno server, and when dev processing, the project works properly without any compile error, But when compiling to build (npm run build), it gives me the folowing error

> npm run build

> @example/basics@0.0.1 build
> astro build

07:16:14 [build] output target: server
07:16:14 [build] Collecting build info...
07:16:14 [build] Completed in 22ms.
07:16:14 [build] Building server entrypoints...
[commonjs--resolver] Cannot bundle Node.js built-in "os" imported from "node_modules\svgo\lib\svgo-node.js". Consider disabling ssr.noExternal or remove the built-in dependency.
file: ..../node_modules/svgo/lib/svgo-node.js
 error   Cannot bundle Node.js built-in "os" imported from "node_modules\svgo\lib\svgo-node.js". Consider disabling ssr.noExternal or remove the built-in dependency.
  File:
  ..../node_modules/svgo/lib/svgo-node.js

because its based on node js libraries, i tried to found some alertnatives with native javascript or works on deno, but my knowledge is not that good . any help or hints ? i can contribute with a PR to make it depends on pure javascript thanks in advance

stramel commented 1 year ago

This definitely seems related to #25. I'm not very familiar with Deno but switching to the browser version of svgo seems like it might resolve the issue temporarily at least.

stramel commented 1 year ago

Will be working on SSR support as part of the next release.

demiro commented 1 year ago

when is the next release coming out? coz I am having problems when trying to build astro (with node)

 error   [astro-icon] Unable to load icon "mdi:account"!
  Error: Unknown builtin plugin "cleanupIDs" specified.
Error: [astro-icon] Unable to load icon "mdi:account"!
Error: Unknown builtin plugin "cleanupIDs" specified.

and I do have svgo set in vite ssr

vite: { ssr: { external: ["svgo"], }, },

stramel commented 1 year ago

I'm going to close this in favor of #35 since both are related to SSR support. Please follow along in there.