unplugin / unplugin-icons

🤹 Access thousands of icons as components on-demand universally.
https://www.npmjs.com/package/unplugin-icons
MIT License
3.65k stars 131 forks source link

Svelte 5 runes mode not working #346

Closed r-unruh closed 2 months ago

r-unruh commented 4 months ago

Describe the bug

If you force your compiler into Svelte 5 runes mode as documented:

export default {
  ...
  compilerOptions: {
    runes: true
  }
}

...and use an icon anywhere in a component, you get the following error:

[vite] Error when evaluating SSR module /src/lib/components/Navbar.svelte: failed to import "~icons/material-symbols/person.svelte"
|- CompileError: Cannot use $$props in runes mode

The solution is to use $props instead of $$props. Of course, this would break Svelte <5 support.

Reproduction

Use Svelte 5 Alpha - opt into runes-only mode - use this library as usual

System Info

System:
    OS: Linux 6.7 Arch Linux
    CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
    Memory: 2.99 GB / 7.64 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 21.6.1 - /usr/bin/node
    Yarn: 1.22.21 - /usr/bin/yarn
    npm: 10.4.0 - /usr/bin/npm
    pnpm: 8.14.0 - /usr/bin/pnpm
  Browsers:
    Chromium: 121.0.6167.139

Used Package Manager

npm

Validations

userquin commented 4 months ago

If you dont enable runes, $props will work? Maybe it is better to add a new svelte-runes compiler updating svelte compiler logic.

r-unruh commented 4 months ago

Yeah, if you don't force runes, $$props will still work in Svelte 5. However, $props will probably be the recommended way soon.

In my opinion, adding a new compiler makes things more complicated for the user. Instead of a straightforward single "svelte" option there would now be choices to make.

userquin commented 4 months ago

my question is about using svelte5 without runes, will $props work?

r-unruh commented 4 months ago

If you excplicitly disable runes mode $props won't work in Svelte 5.

Which is a good point.