-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
reduce size (adds 110kb to bundle) #103
Comments
I noticed this too and ended up replacing with |
It's quite confusing to me. There's no clear culprit, other than the generated code being huge. There are a few things that would help (eg extracting out the svg, or making it a raw string), but no clear low hanging fruit. I think Svelte 5 will reduce the bundle size a fair bit. |
replacing svgs with |
My app
After adding
So it adds 64k, and 20k minified. A lot more reasonable. |
250.80 kB with, 191.62 kB without (minified: 102.6 kB / 79 kB). So around 50% less than svelte 4. Which is a lot better. 24kb minified is still a bit on the larger side though. |
What are you using as your bundler? @mustafa0x I'm not seeing that massive increase in size, but I'd like to investigate if you can give me a reproduction repo. It'd help a ton! Thanks! Looking at your output it appears a ton of lines come from the conditionals in the slot props. I'm curious what you're able to produce as a bundle output side on this branch (which is rewritten in Svelte 5): https://github.com/huntabyte/svelte-sonner/tree/svelte-5 |
i'm using vite (ie rollup). repro: https://github.com/mustafa0x/sonner-size plain sv5 app
after adding sonner
with minifcation: # no sonner
dist/bundle.es.js 11.91 kB │ gzip: 4.11 kB
# sonner
dist/bundle.es.js 66.83 kB │ gzip: 19.28 kB +55kb minified! not sure why more than the +24kb i got above. maybe because it was a larger app, so the svelte utils/anims/transitions were added to the bundle in all cases. also i was using terser above, which minifies a little better than esbuild (which vite uses). |
pkg.json: pnpm vite build:
|
First, thanks for svelte-sonner. It's quite a nice toast component.
Second, I replaced my hand rolled toast component with sonner, and saw bundle.es.js grow by 110kb (50kb after minifying). I didn't expect such an increase!
I diffed the bundles to see if there was a single culprit. However it was mostly the generated svelte code for the sonner component. So there doesn't seem to be any simple fix to this problem.
I copied the added code to a gist (4k lines!), for whomever is curious to see what was added.
The text was updated successfully, but these errors were encountered: