Skip to content
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

Provide ability to tree-shake parsers. #215

Open
bheston opened this issue Nov 30, 2023 · 2 comments
Open

Provide ability to tree-shake parsers. #215

bheston opened this issue Nov 30, 2023 · 2 comments

Comments

@bheston
Copy link

bheston commented Nov 30, 2023

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.

@danburzo
Copy link
Collaborator

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 {}.

@bheston
Copy link
Author

bheston commented Dec 5, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants