feat(css): emit named exports for JS keyword class names in CSS modules#22393
Open
semimikoh wants to merge 1 commit into
Open
feat(css): emit named exports for JS keyword class names in CSS modules#22393semimikoh wants to merge 1 commit into
semimikoh wants to merge 1 commit into
Conversation
3a8f159 to
f216993
Compare
sapphi-red
requested changes
May 21, 2026
Member
sapphi-red
left a comment
There was a problem hiding this comment.
I think this will break existing apps when the app targets browsers that does not support the arbitrary names feature.
I guess we need to conditionally enable this when the target supports them. or maybe we can transpile it somehow.
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.
CSS modules containing class names that match JavaScript reserved keywords
(e.g.
switch,if,for,class) were not emitted as named exports,making them accessible only via the default export object.
Summary
dataToEsmskips named export generation when a key fails thekey === makeLegalIdentifier(key)check — reserved words likeswitchget prefixed to
_switch, so they never matchincludeArbitraryNames: trueoption to thedataToEsmcall incssPostPlugin, which emits string-named exports for such keys:export { _arbitrary0 as "switch" }(
styles.switch) or string literal import (import { "switch" as s })Related
Fixes #14050
Test plan
Added playground test case with a CSS module containing a
.switchclass,verifying it is correctly applied via
import * as keywordModandkeywordMod.switch