withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
47.19k stars 2.51k forks source link

Svelte 5: named snippets results in vague errors #11400

Closed murl-digital closed 4 months ago

murl-digital commented 5 months ago

Astro Info

Astro                    v4.11.3
Node                     v22.3.0
System                   Linux (x64)
Package Manager          bun
Output                   static
Adapter                  none
Integrations             unocss
                         @astrojs/svelte
which: no xclip in (/tmp/bunx-1000-astro@latest/node_modules/.bin:/home/draconium/Desktop/repos/drac.gay/node_modules/.bin:/home/draconium/Desktop/repos/drac.gay/node_modules/.bin:/home/draconium/Desktop/repos/node_modules/.bin:/home/draconium/Desktop/node_modules/.bin:/home/draconium/node_modules/.bin:/home/node_modules/.bin:/node_modules/.bin:/home/draconium/.pyenv/shims:/usr/local/sbin:/usr/local/bin:/usr/bin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/opt/rocm/bin:/usr/lib/rustup/bin:/home/draconium/.local/bin:/home/draconium/.cargo/bin:/home/draconium/.local/bin:/opt/postgresql16/bin)

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

Describe the Bug

I have a usecase where I want a second named slot (snippet in the case of svelte 5), but trying to do so the way the svelte 5 docs wants me to results in an esbuild error, and a different error about a validate snippet function not existing in some cases.

What's the expected result?

To be able to use svelte snippets in an astro component

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-3etiww?file=src%2Fpages%2Findex.astro

Participation

bluwy commented 4 months ago

You cannot use Svelte snippets in an Astro file. They're a Svelte-file only feature as they need to be compiled by the Svelte compiler. You should use Astro's slots feature instead, which is compatible when passed to the Svelte component's slots.