-
Notifications
You must be signed in to change notification settings - Fork 242
Description
Problem description
As mentioned in the comment below:
This happens as part of
stylesheet.minify(). So make sure you're calling that, even in development mode (bad name, it should really be calledstylesheet.transformbecause it does more than minification).
Originally posted by @devongovett in #935
StyleSheet::minify always needs to be called before calling StyleSheet::to_css, even in debug mode. As mentioned in the comment, minify should probably be renamed to transform
This has resulted in fixes being made such as the one below:
However, this behaviour is confusing and prone to incorrect usage. The issue below from cargo-leptos is confirmed to be caused by not calling minify due to the naming confusion, and the other comment may be experiencing the same thing:
- Invalid usage of lightningcss in debug mode breaks variables referencing light-dark leptos-rs/cargo-leptos#622
light-darkis broken when children have differentcolor-scheme's #821 (comment)
The following js related issues can probably be addressed by applying the version of turbopack containing the fix above:
- border-color is not applying color correctly with light-dark() #831
- Invalid CSS generation with color-scheme and light-dark() function #873 (comment)
There may be other issues caused by this, probably anything that writes custom variables that were initially defined during the logic in minify, although I haven't taken the time to look for these.
Possible solutions
- Easy: rename
minifytotransform, and make it explicitly clear in the doc comments of both functions (transformandto_css) thattransformALWAYS needs to be called beforeto_css - deprecate both functions, and unify them into a single function which performs the logic of both, eventually making the prior functions private or hiding them behind a feature flag
I personally prefer option 2, as I think that implicit calling requirements like these are inherently bad, especially in library code. Additionally, I am not sure what the benefit of being able to call them separately is, but have not taken the time to look into this much. Perhaps others can comment on this. At the very least, I think that most users of the library probably want the combined version, and thus this should be indicated somewhere very explicitly.
Open to other suggestions as well