techniq / svelte-ux

Collection of Svelte components, actions, stores, and utilities to build highly interactive applications.
https://svelte-ux.techniq.dev/
MIT License
808 stars 45 forks source link

Investigate package size (consider `sideEffect`) #124

Open techniq opened 11 months ago

techniq commented 11 months ago

It would be useful to make sure our bundle size is as small as possible, and we are leveraging tree shaking as well.

It would be great to track our bundle size over time (with actual usage, not just full NPM size).

We might want to investigate the sideEffect NPM config. I remember this being looked at for d3 and three.js years ago. Also wasn't sure if it's only useful for webpack (and still applicable for rollup/vite)

techniq commented 11 months ago

Spent a little bit of time trying to look into the install and bundle size of Svelte UX and it's dependencies (with bundle being the most important).

Using pkg-size.dev provides some useful insights:

image

Shows the total install size as 149MB, with 109MB attributable to sveld, although the top graph shows the top dependency as typescript at 67MB.

Using bundlephobia.com show the bundle as 2.5kB minified, and the biggest contributor is self, followed by date-fns and lodash-es (which seems more reasonable for bundle size).

image

Using packagephobia.com, it doesn't provide much insight other than bundle size of 618kb and install size of 143MB

image

When I tried to use bundlejs.com, it didn't provide much useful information, but probably because I don't fully understand how to use it, especially with Svelte.

image

Using npm.anvaka.com it helps to show the dependency tree as a graph, with most of the dependencies comes as the result of @changesets/cli (everything not in the green outline).

image


While there isn't strong evidence from the above, I think the following could be helpful..

techniq commented 11 months ago

Also took a look at a few small projects I've built with Svelte UX, and attemped to ignore the data/API portion

Site DevTools Download Resources
image image 434kB 687 kB
image image 188kB 526 kB
image image 97.2kB 287 kB

They all seemed reasonable.

techniq commented 11 months ago

Ran a couple quick lighthouse scores (for performance number), and they came back promising as well

image

image

techniq commented 11 months ago

Consider installing https://github.com/btd/rollup-plugin-visualizer (although based on PRs for Rollup v4, it doesn't look actively maintained at the moment).