-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Raw snippet alternative #12425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raw snippet alternative #12425
Conversation
🦋 Changeset detectedLatest commit: 7239cbb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
As per the other thread: #12409 (comment) |
Just needs docs then we’re good to go |
Oops, good catch |
@bluwy does this version of the raw snippet API work for Astro, too? |
sites/svelte-5-preview/src/routes/docs/content/01-api/05-imports.md
Outdated
Show resolved
Hide resolved
I updated https://github.com/withastro/astro/tree/svelte-5-slots-fix and it seems to work fine too. (I also made additional changes for snippet children to work) |
Why not simply createSnippet? |
This isn't something most people should be using, and instead should be using |
@trueadm @Rich-Harris how can one use an existing component inside import { createRawSnippet, mount } from 'svelte';
import Counter from './lib/Counter.svelte'
export const counterSnippet = createRawSnippet(() => {
return {
render: () => `<h1>Count: 0</h1>`,
setup: (node) => {
mount(Counter, {
target: node
})
}
};
}); But this doesnt make sense because I have a different content when rendering. Or am I understanding this wrong? |
You can do this... svelte/packages/svelte/tests/runtime-runes/samples/snippet-raw-component/main.svelte Lines 1 to 20 in a8f964c
...though there's currently a bug with hydration (we don't reset hydration state after the snippet has been hydrated, causing the larger app to subsequently crash) that is fixed in #12512 |
Alternative to #12409 (but see #12409 (comment)):
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint