-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
feat: adds legacy mode flag #14180
feat: adds legacy mode flag #14180
Conversation
🦋 Changeset detectedLatest commit: 8899263 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 |
|
Nice ! Out of curiousity: how much savings are we talking about (in kb, unminified or minified, I don't care) |
What if we move |
@dummdidumm It's variable depending on what you use. For a simple component: <script>
let x = $state(0);
let { y = 0 } = $props();
</script>
<button onclick={() => x++}>{x}</button>
{y} So a 0.3kb saving on a simple component, but still a saving! |
@Rich-Harris Applied your feedback :) |
to not regress, we should add a test similar to the one checking that hydration code is treeshaken out ( |
@dummdidumm Mind helping me do that? Not sure what we should check for in the code. |
it's not an exact science. Basically you pick a string that shouldn't be present anymore after treeshaking, like |
@dummdidumm Thanks, done that now |
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 changeset needs to be different, IMO. It doesn't describe what's happening to an end user at all. And it should also probably be a fix
or chore
because there's no visible API changes.
@Conduitry Is that better? |
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.
Yup sounds good 👍
* feat: adds legacy mode flag * feedback * feedback and tweaks * feedback and tweaks * tweaks * tweaks * tweaks * tweaks
This PR makes it so Svelte components that are in legacy mode mark the legacy mode flag and adds the flag to parts of the codebase that do checks for runes. In practice this means that if all your components are in runes mode, Rollup can strip out all the runtime code that handles legacy mode, reducing bundle code-size and improving runtime performance.
I was expecting bigger wins, but some small gains are better than nothing! Notable wins are inside our props logic and await blocks. Some hot paths are also improved as it means less
is_runes
lookups.I also considered adding a DEV time
console.info
message if you have a component that is in legacy mode to help inform the user, but this might be a bit noisy on reflection so I decided against it.