-
-
Notifications
You must be signed in to change notification settings - Fork 2k
fix: use runes in when detecting Svelte 5 #11028
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
Conversation
🦋 Changeset detectedLatest commit: 931f522 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking forward to replacing the stores with state-based alternatives so that this dance becomes unnecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary? I don't see anything in the Svelte 4 version that's listed on the breaking changes page: https://svelte-5-preview.vercel.app/docs/breaking-changes. If I didn't miss it, then maybe there's something we need to fix in our compatibility or list on that page?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually @benmccann is right, this should work. i'm rescinding my approval
@trueadm this is what i was talking about before when i was saying afterUpdate
shouldn't be bound to render effects, it should be bound to get
I also opened an issue in the svelte repo with a much more minimal reproduction sveltejs/svelte#9420 |
What exactly should work? Are you saying that you also expect |
@Rich-Harris The issue with all of this (we currently do |
I also don't think |
|
I'd prefer: $effect.once(fn) This would be an effect that runs one on the server and once on init on the client. Which seems to handle this use-case? |
This is basically onMount, with added functionality of running on server. Could be handy, but necessary? |
It is not what's wanted here. What's wanted here is a function that runs once on the server and before every update on the client (basically |
Maybe we can detect cascading updates in |
I think my solution to that problem would instead be to detect in dev mode that the value on the client differs from the value on the server. Because it seems unusual to me that something would run twice on the client before hydration and once on the server and that seems like something to avoid |
@benmccann I mean the same logic would also run twice on the server if it could – but given we're saying that The way other frameworks deal with this problem is to make it not possible to run effects on the server, and then making it clear there was a mismatch on the client – meaning there's a single place to look to fix it, the client code. In which case the fix is generally to make it an This is important as I expect the majority of use-cases for |
This seems like something you'd do frequently with stores. I think another solution to this might be to replace the use of |
@benmccann There was a suggestion to have a |
No, absolutely not and I'm not sure what |
Where the signal was created is irrelevant — what matters is where the signal is read. What I'm suggesting is basically this (pseudo-code): function get(signal) {
if (current_component) {
signal.consumers.add(current_component);
}
// ...
} |
We should have the "how does
I don't understand what changes you are requesting to this PR then. If anything, this fixes the |
I tried that and the issue is |
What I'm saying is that we shouldn't need to remove the |
Yeah I'm not talking about what |
But it's deprecated, and we're encouraging people to move away from it. It is counter-intuitive to not use the new tools we have in runes mode. And it's a quick-fix for the issue in the context of SvelteKit, and we can look at the underlying problem in sveltejs/svelte#9420, where - again - we should have the discussion about how to fix this. |
The replacement code is just super nasty. I think it would be better to keep using |
It's not pretty, but it's a 1-for-1 replacement to get the behavior we want (we can probably remove components and constructors from that list). It's ok IMO, and allows us to fix this issue in SvelteKit. Depending on how we need to adjust |
I'm fine with this PR for the time being if we can file an issue to address or document the breaking change so that we don't forget to do so |
ok — i think we should undo the |
Yeah, let's do that. I think it makes most sense. |
.changeset/beige-ties-allow.md
Outdated
'@sveltejs/kit': patch | ||
--- | ||
|
||
fix: use runes in when detecting Svelte 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changelog message appears to be missing a
Someone made a related issue: sveltejs/svelte#9278 |
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.