culori icon indicating copy to clipboard operation
culori copied to clipboard

Provide ability to tree-shake parsers.

Open bheston opened this issue 2 years ago • 2 comments

Overall I'm good with the size of the library when I shake out the modes I don't need. CSS named colors are not very useful though, and really that's the only other thing I'd like to shake out. Can we opt-in to named color parsing? I suspect a lot of people are only dealing with hex values for modern experiences.

bheston avatar Nov 30 '23 19:11 bheston

Hi @bheston, it would indeed be a nice thing to figure out, but I don’t see a solution given the current way things are organized.

In the meantime, if minimal payload is crucial, it may be worth experimenting with build-time optimizations such as using import maps (or other bundler features such as Rollup Transformers) to replace the content of colors/named.js with a dummy export default {}.

danburzo avatar Nov 30 '23 22:11 danburzo

Thanks. Yeah, I didn't see a good way to handle it either. I was considering copying and modifying the modeRgb definition to remove the reference to parseNamed and then only use my local definition. It seems like that would work, though runs the risk of getting out of sync.

I wonder if all of the mode definitions exported all of the pieces if someone could build their own mode definitions without the potential for losing as much as if I were to copy that entire file.

I recently came across this which I think is a similar idea: https://github.com/antfu/shikiji?tab=readme-ov-file#fine-grained-bundle

bheston avatar Dec 05 '23 03:12 bheston