Merged
Conversation
This was referenced May 22, 2022
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.
This adds support for hashing CSS dashed idents (i.e.
--foo), most commonly CSS variables, just like other custom idents in CSS modules (e.g. class names). This is opt-in because it was not originally handled by the CSS modules support in other tools.Hashing dashed idents keeps these declarations local to the module just like other names in CSS modules. The names are included in the mapping passed to JS just like other names as well, meaning you can reference a CSS variable like this:
This also means which variables are used can be tracked across files, and unused variable declarations can be automatically removed! Closes #58.
By default, all variable references are scoped to the module, so you can only reference variables declared in that file. A syntax extension has been added so that identifiers can be referenced between different CSS files. It is similar to the
composesproperty.You can also reference a global variable like this:
This applies not only to CSS variables but anywhere the
<dashed-ident>production is used in CSS. Right now that means@font-palette-valuesand@property, but others such as@custom-mediaand@color-profileare coming.All of this is only enabled when the
dashedIdentsconfig option is turned on.{ "cssModules": { "dashedIndents": true } }