dylanblokhuis / svelte-feather-icons

https://www.npmjs.com/package/svelte-feather-icons/
MIT License
136 stars 21 forks source link

Playing nice with SvelteKit #11

Closed acoyfellow closed 3 years ago

acoyfellow commented 3 years ago

First of all, thanks for this library. I've been using it in production for a while now with Sapper.

Testing SvelteKit out, i notice that you get a SSR error out of the box: https://svelte.dev/blog/whats-the-deal-with-sveltekit

How to reproduce:

acoyfellow commented 3 years ago

I also notice this problem is the exact same as svelte-hero-icons out of the box (ssr error). So, my apologies if this isn't the right place for this discussion. But, I'm now wondering what I can do to help fix this experience within svelte-feather-icons for sveltekit, potentially before it even releases.

dylanblokhuis commented 3 years ago

Testing this locally I also noticed that many other built Svelte components on NPM are having issues with this. I assume this is an issue within SvelteKit.

peterszerzo commented 3 years ago

Sapper throws the same error:

500
<FrownIcon> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules

Error: <FrownIcon> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules
    at validate_component (/Users/peterszerzo/Documents/projects/nlx/vc-template-3/node_modules/svelte/internal/index.mjs:1343:18)
    at /Users/peterszerzo/Documents/projects/nlx/vc-template-3/__sapper__/dev/server/server.js:233:7
    at Object.$$render (/Users/peterszerzo/Documents/projects/nlx/vc-template-3/node_modules/svelte/internal/index.mjs:1366:23)
    at Object.default (/Users/peterszerzo/Documents/projects/nlx/vc-template-3/__sapper__/dev/server/server.js:297:42)
    at /Users/peterszerzo/Documents/projects/nlx/vc-template-3/__sapper__/dev/server/server.js:168:34
    at Object.$$render (/Users/peterszerzo/Documents/projects/nlx/vc-template-3/node_modules/svelte/internal/index.mjs:1366:23)
    at Object.default (/Users/peterszerzo/Documents/projects/nlx/vc-template-3/__sapper__/dev/server/server.js:295:59)
    at /Users/peterszerzo/Documents/projects/nlx/vc-template-3/__sapper__/dev/server/server.js:157:166
    at Object.$$render (/Users/peterszerzo/Documents/projects/nlx/vc-template-3/node_modules/svelte/internal/index.mjs:1366:23)
    at /Users/peterszerzo/Documents/projects/nlx/vc-template-3/__sapper__/dev/server/server.js:294:56

As far as I understand, these frameworks would need compiled components instead of Svelte files to work with SSR - so in this light I don't think it's a Sapper/SvelteKit issue.

dylanblokhuis commented 3 years ago

Sapper throws the same error:

500
<FrownIcon> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules

Error: <FrownIcon> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules
    at validate_component (/Users/peterszerzo/Documents/projects/nlx/vc-template-3/node_modules/svelte/internal/index.mjs:1343:18)
    at /Users/peterszerzo/Documents/projects/nlx/vc-template-3/__sapper__/dev/server/server.js:233:7
    at Object.$$render (/Users/peterszerzo/Documents/projects/nlx/vc-template-3/node_modules/svelte/internal/index.mjs:1366:23)
    at Object.default (/Users/peterszerzo/Documents/projects/nlx/vc-template-3/__sapper__/dev/server/server.js:297:42)
    at /Users/peterszerzo/Documents/projects/nlx/vc-template-3/__sapper__/dev/server/server.js:168:34
    at Object.$$render (/Users/peterszerzo/Documents/projects/nlx/vc-template-3/node_modules/svelte/internal/index.mjs:1366:23)
    at Object.default (/Users/peterszerzo/Documents/projects/nlx/vc-template-3/__sapper__/dev/server/server.js:295:59)
    at /Users/peterszerzo/Documents/projects/nlx/vc-template-3/__sapper__/dev/server/server.js:157:166
    at Object.$$render (/Users/peterszerzo/Documents/projects/nlx/vc-template-3/node_modules/svelte/internal/index.mjs:1366:23)
    at /Users/peterszerzo/Documents/projects/nlx/vc-template-3/__sapper__/dev/server/server.js:294:56

As far as I understand, these frameworks would need compiled components instead of Svelte files to work with SSR - so in this light I don't think it's a Sapper/SvelteKit issue.

The components are compiled if you import them normally e.g. import { XIcon } from 'svelte-feather-icons'

peterszerzo commented 3 years ago

It is what I'm doing in this example. So steps to reproduce:

dylanblokhuis commented 3 years ago

I just tested with https://github.com/sveltejs/kit and the package works fine.

acoyfellow commented 3 years ago

It has to be listed under deps not devDeps, and latest SK works

bhargawananbhuyan commented 1 year ago

Use sveltekit-feather-icons. It’s a small package and works well with SvelteKit.