Add granular CSS Modules options#739
Merged
devongovett merged 9 commits intoparcel-bundler:masterfrom May 15, 2024
Merged
Conversation
devongovett
reviewed
May 15, 2024
napi/src/lib.rs
Outdated
| dashed_idents: c.dashed_idents.unwrap_or_default(), | ||
| animation: c.animation.unwrap_or_default(), | ||
| grid: c.grid.unwrap_or_default(), | ||
| custom_idents: c.custom_idents.unwrap_or_default(), |
Member
There was a problem hiding this comment.
These should probably default to true like below.
src/properties/animation.rs
Outdated
| W: std::fmt::Write, | ||
| { | ||
| let css_module_animation_enabled = | ||
| dest.css_module.as_mut().map_or(false, |css_module| css_module.config.animation); |
Member
There was a problem hiding this comment.
Suggested change
| dest.css_module.as_mut().map_or(false, |css_module| css_module.config.animation); | |
| dest.css_module.as_ref().map_or(false, |css_module| css_module.config.animation); |
devongovett
reviewed
May 15, 2024
src/values/ident.rs
Outdated
| .as_mut() | ||
| .map_or(false, |css_module| css_module.config.custom_idents); | ||
|
|
||
| dest.write_dashed_ident(&self.0, true, css_module_custom_idents_enabled) |
Member
There was a problem hiding this comment.
write_dashed_ident already checks the dashed_idents option. I'm not sure that the custom_idents option also needs to affect dashed idents as well?
devongovett
reviewed
May 15, 2024
src/properties/animation.rs
Outdated
| AnimationName::None => dest.write_str("none"), | ||
| AnimationName::Ident(s) => { | ||
| if let Some(css_module) = &mut dest.css_module { | ||
| css_module.reference(&s.0, dest.loc.source_index) |
e38e6bd to
39f4311
Compare
39f4311 to
e5d9ca1
Compare
devongovett
approved these changes
May 15, 2024
kdy1
added a commit
to vercel/turborepo
that referenced
this pull request
May 23, 2024
Reverts #8060 parcel-bundler/lightningcss#739 is now applied so we don't need this lint anymore
ForsakenHarmony
pushed a commit
to vercel/next.js
that referenced
this pull request
Jul 25, 2024
Reverts vercel/turborepo#8060 parcel-bundler/lightningcss#739 is now applied so we don't need this lint anymore
ForsakenHarmony
pushed a commit
to vercel/next.js
that referenced
this pull request
Jul 29, 2024
Reverts vercel/turborepo#8060 parcel-bundler/lightningcss#739 is now applied so we don't need this lint anymore
ForsakenHarmony
pushed a commit
to vercel/next.js
that referenced
this pull request
Jul 29, 2024
Reverts vercel/turborepo#8060 parcel-bundler/lightningcss#739 is now applied so we don't need this lint anymore
ForsakenHarmony
pushed a commit
to vercel/next.js
that referenced
this pull request
Aug 1, 2024
Reverts vercel/turborepo#8060 parcel-bundler/lightningcss#739 is now applied so we don't need this lint anymore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change in this PR
Adds granular options to switch on/off CSS module scoping for CSS features that are prefixed by default in Lightning CSS currently. For example animation, grid, and custom identifiers.
The reason this is useful is that for example Webpack's CSS modules implementation does not do prefixing of
grid. If you're migrating to Lightning CSS, like we're doing in Next.js / Turbopack it's helpful to disable the grid prefixing feature to ensure people have a smooth experience migrating.Last test failure
The PR is mostly done, just one more case with
animation: falsewhere it somehow usesCustomIdentwhich in turn means it still prefixes.PR feedback
I'm not proficient in writing Rust currently, using working on these smaller changes in Turbopack and other deps of Turbopack to learn as well, let me know if anything should be changed 👍
Improved
assert_eqfailure reports in testsWhile investigating mismatches it was quite hard to read the
assert_eqfor these outputs when they mismatch. Addedpretty_assertionsto add much better diffs for these cases:Before:
After: