flekschas / svelte-simple-modal

A simple, small, and content-agnostic modal for Svelte v3 and v4
https://svelte.dev/repl/b95ce66b0ef34064a34afc5c0249f313
MIT License
422 stars 30 forks source link

Kb size different on bundlephobia #30

Closed websocket98765 closed 3 years ago

websocket98765 commented 3 years ago

Any idea why the kb size in the repo is different from the size shown on bundlephobia ?

Do you know which is more accurate? Does it change significantly after Svelte's build step too?

flekschas commented 3 years ago

The repo one looks just at Modal.svelte, which is the component you would bundle with your app. (See the source code of README.md) Bundlephobia is looking at the one of the compiled files.

Do you know which is more accurate?

More accurate in terms of what? Both are accurate but they describe different file types. If you're looking at the size of Svelte code that this package adds then you can say it adds 2.18 KB (gzipped). If you're looking at the bundled size then it might be more because .svelte has to be translated to .js, which will incur some overhead. But my guess is that the overhead is a one-time aspect and is neglectable (assuming you have more components than just a modal).

Does it change significantly after Svelte's build step too?

I don't know what is significant for you so I am listing some raw numbers:

Modal.svelte Size: 7.2KB CommonJS Size: 36.31 KB (converted from .svelte to .js) CommonJS Minified Size: 16.92 KB CommonJS Gzipped Size: 5.89 KB

Again, I don't know how much overhead is added by converting from .svelte to .js but my guess is the overhead is a one-time thing.

websocket98765 commented 3 years ago

Bundle size would be the one that matters. Sounds like ~5.7-5.8 kb gzip is the most realistic Kb size that it adds to a build. I appreciate the details. Thanks

flekschas commented 3 years ago

The KBs that this package will add is somewhere between 2.2 and 5.8 KB because your bundler is smart enough to only include Svelte's utility functions once. However, how smart the bundle is independent of this package so I only report the size of the source code, which is 2.2 KB (gzipped).