-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
Color spaces are not tree-shakeable #163
Comments
Thank you for spending so much effort working on a procedural API 🙇 That massively helps with keeping bundle sizes down!
Yes, that's what I see as the greatest difficulty in using the current color space approach for everything. Would it be feasible to make parsing and serialization self-sufficient within each colour space? The way the top-level |
|
Yeah, an optional list of color spaces would likely do the trick here 👍 That would allow for use of the function while having an empty registry.
|
This should have been auto closed after #184 was merged, so I'm gonna manual close it. |
FYI https://colorjs.io/docs/spaces.html says that this issue is open – should that be removed from the page? |
Oops, yes! PR? |
I’m sorry, but I’ll pass on that this time! 😊 |
Can you open a new issue then since this is closed? |
Sure thing! Opened a new issue: #204 |
(Remaining part of #159)
While the new procedural API is tree-shakeable wrt functions, since color spaces register themselves onto
ColorSpace.registry
, this means they are not tree-shakeable.To make them tree-shakeable, we'd need to eliminate side effects from the color space modules. Then, the importing code would register them.
Something like:
We could make this less painful by offering pre-generated indices that do this for all existing color spaces, but I'm still struggling with the idea of requiring more plumbing to use Color.js, which makes it easier to make mistakes. E.g. someone could easily forget to register their color space and do something like:
Note that registration is needed only to use string ids instead of color space objects. The API is perfectly usable with just passing identifiers around and never registering any color space, like so:
Thoughts?
The text was updated successfully, but these errors were encountered: