-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
Describe the problem
First off: I've been using Svelte since v1, and I really admire the tool and the team! The work on the Svelte 5 rewrite is particularly impressive, especially with so few breaking changes.
My issue is that I'm using Svelte to build a standalone component: emoji-picker-element. I'm using Svelte because it's one of the most lightweight frameworks in terms of bundlesize, especially for authoring a single component.
When upgrading from Svelte 4 to Svelte 5, I noticed that the bundle size increased by 20% compressed (42.8kB -> 51.2kB), even though I adopted snippets to reduce some duplication. The main cause of the new increase seems to be transition and hydration code, which I'm not using for this component. (nolanlawson/emoji-picker-element#376)
Previously I had been using some small hacks to remove unused code (e.g. replacing options.hydrate
with false
), but with Svelte 5, these techniques don't seem to work anymore. And unfortunately the new code is much more tightly-integrated into the Svelte framework code, so it's difficult to remove using simple string replacement.
Describe the proposed solution
I guess my request is:
- If a component is not using transition code, then it should be possible to tree-shake transition-related code somehow.
- Ditto for hydration code.
Alternatives considered
To be sure, this is not a must-have feature. And someone building a large app with hundreds of components is not going to care about a one-time bundle size cost. But I think it would be great for Svelte to be useful for portable, single components (ideal for the custom element build target!).
I'm also excited that the changes in Svelte v5 should theoretically allow for even more bundlesize savings (HTML strings instead of manual DOM operations, plus snippets to reduce duplication).
In any case, thanks for considering it!
Importance
nice to have