csstree / csstree

A tool set for CSS including fast detailed parser, walker, generator and lexer based on W3C specs and browser implementations
https://csstree.github.io/docs/
MIT License
1.85k stars 84 forks source link

consider dropping some builds #255

Open benmccann opened 1 year ago

benmccann commented 1 year ago

I wanted to suggest some changes that would make the package size a bit smaller. These are breaking changes, so would probably have to be done with the next major version.

The motivation for this suggestion is that learn.svelte.dev loads all Svelte dependencies and css-tree is the largest of those dependencies at 1.3 MB. If we're able to slim this down a bit then the tutorial could load a little faster for users.

One idea I had was possibly dropping the browser builds under dist. These are bundled versions of css-tree which makes it possible to load css-tree from a CDN. I would guess that the majority of users get css-tree from npm. The remaining users could switch to npm and build their own bundle saving 499 kB from the css-tree package.

Another, probably more controversial, idea would be dropping the CJS build. As more and more users switch to ESM the CJS build becomes less necessary and becomes extra weight. The cjs folder is 403 kB. ESM users can use the ESM version directly. CJS users can use the ESM version via dynamic import.