Add experimental.lightningCssModules config option#95444
Open
UditDewan wants to merge 1 commit into
Open
Conversation
Allows configuring how lightningcss processes CSS Modules in Turbopack: a custom naming pattern for scoped class names and toggles for scoping @Keyframes names, grid line names, custom idents, dashed idents, and @container names. Defaults preserve the previously hardcoded behavior.
|
🙌 |
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.
What?
Adds a new experimental config option,
experimental.lightningCssModules, that exposes Lightning CSS's CSS Modules options when bundling with Turbopack:Supported options:
pattern(custom naming patterns) and the feature-scoping togglesanimation,grid,customIdents,dashedIdents,container(turning off feature scoping).Why?
Turbopack always processes CSS Modules with Lightning CSS using a hardcoded configuration (
[name]__[hash]__[local]pattern, animation scoping on). Users repeatedly asked in discussion #64580 for a way to:@keyframesrenaming, to match webpack'scss-loaderbehavior when migrating to Turbopackexperimental.lightningCssFeatures(#90901) only controls feature transpilation flags and does not cover CSS Modules options, so there is currently no escape hatch at all on Turbopack.How?
CssModulesOptionsstruct inturbopack-css, threadedNextConfig→CssOptionsContext→ModuleType::Css→CssModule→parse_css/process_content, following the same path aslightningcss_features(Add experimental.lightningCssFeatures config option #90901).[name]__[hash]__[local],animation: true,grid: false,customIdents: true,dashedIdents: false,container: false), so behavior is unchanged unless configured.patternis validated once at config level so a typo produces a single clear error naming the config key instead of one error per CSS file. The pattern string is interned so the parsedPatterncan borrow into the'staticparser options stored inParseCssResult.css-loaderhandles that and is already configurable), so this option is Turbopack-only; a warning is logged when it is set with another bundler.animation: false, plus documentation inuseLightningcss.mdx.Addresses the CSS Modules configuration requests in #64580.