Components in Svelte 5's own syntax: runes, snippets, event attributes - #231
Merged
Merged
Conversation
The follow-up to the Svelte 5 upgrade. Svelte's migrate() rewrote 76 of the 142 components (the other 66 had no props or reactivity to convert); the rest of this commit is what it could not do, or got wrong: - Button: migrate() put the external-link test before $props() — a ReferenceError at prerender — and forwarded clicks through createBubbler. Props are declared first now, the link test is $derived, and onclick arrives with the rest of the props; the one on:click on a Button became onclick. - AppPicker: the chosen app is $state.raw. Deep state wraps the object in a proxy, which equals none of the apps the chips compare it with, and the chosen chip lost its ink. The guess-the-language rounds are raw too, being only ever replaced. - run() stopgaps replaced: SpeakButton's audio check and the say page's sprite swap are effects; the meaning quiz starts with one slot per round, so the server renders the same track as before, and resets before render. The say page's sprite is a plain variable, as nothing renders from it. - The globe and mark containers are typed as possibly unset, asserted where onMount uses them; the inview action's event is typed as onenter. - Values taken once from props, as Svelte 4 did too, are marked as meant. - The error page reads $app/state instead of the $app/stores store. - NewsletterForm goes: nothing imported it. The blog posts and legal pages stay in the old syntax; that is what mdsvex writes, and Svelte 5 runs both. Checked against the build of the upgrade commit: all 1371 pages have the same element tree, text and head; computed styles match on 16 page types; in the browser the compare picker, FAQ, quizzes, vocabulary test, word game, word list search and paging, say pages across client navigation and the globe all work, with no console errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 2 of the Svelte 5 move, after #230. Svelte's
migrate()(whatnpx sv migrate svelte-5runs) rewrote 76 of the 142 components; the other 66 had no props or reactivity to convert. The rest is what it could not do or got wrong:$props()(a ReferenceError at prerender) and clicks went throughcreateBubbler. Props come first, the test is$derived, andonclicktravels with the rest props; the oneon:clickon a Button becameonclick.$state.raw. Deep state returns a proxy that equals none of the apps, so the chosen chip lost its highlight. Guess-the-language rounds are raw too.run()stopgaps replaced: SpeakButton and the say page use effects; the meaning quiz starts with one answer slot per round, so the server renders the same track as before.onenterevent type of the inview action, intended one-time reads of props marked,$app/stateon the error page, and the unused NewsletterForm removed.Blog posts and legal pages stay in the old syntax, which is what mdsvex writes; Svelte 5 runs both.
Checked
?vs=, clicks, chip highlight), FAQ, meaning quiz, guess the language, vocabulary test, word game, word list search and paging, say pages across client-side navigation, globe and mark. No console errors.🤖 Generated with Claude Code