SIGN IN SIGN UP

fix: multiple bugfixes and optimizations in CSS modules (#20648)

- Fix third code point position in walkCssTokens number detection (pos → pos+1)
- Fix multiline CSS comment regex to match across line breaks
- Fix swapped :import/:export in error message
- Fix comma callback incorrectly popping balanced stack, causing stray ')' in output
- Fix cache comparison missing inheritance array length check
- Fix match.index mutation side effect in publicPathAutoRegex replacement
- Fix typo GRID_TEMPLATE_ARES → GRID_TEMPLATE_AREAS
- Remove duplicate grid-column-start property setting
- Move publicPathAutoRegex to module scope to avoid repeated construction
- Precompute merged callbacks in consumeUntil to avoid per-token object spread
- Simplify redundant nested ternary in CssGenerator
- Replace spread+reduce with for-of loop for Map→Object conversion
- Merge duplicate getCompilationHooks calls in CssLoadingRuntimeModule

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: update snapshots for CSS module bugfixes

Update walkCssTokens snapshot for correct number token parsing (-.1, +.1
now correctly recognized as number tokens instead of delim + number).
Update postcss-modules-plugins snapshots for correct :local() comma
handling (stray ')' no longer in output).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: add multiline CSS comment test cases for @value rule

Add three test cases with multiline comments in @value declarations:
- @value with multiline comments around name, colon, and value
- @value import with multiline comments around name, from, and request
- @value empty with multiline comment as value

These cover the CSS_COMMENT regex fix (.*? → [\s\S]*?) ensuring
multiline comments are correctly stripped during @value parsing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: update ConfigCacheTestCases snapshot for multiline CSS comment tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: remove obsolete ConfigCacheTestCases snapshots

Clean up 94 obsolete snapshots for chunks-order, import-meta-env,
and extract-source-map-css test cases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* update

* Revert "test: remove obsolete ConfigCacheTestCases snapshots"

This reverts commit 652e2f0265a6247a797e78334a3fe4a928034833.

* test: update ConfigCacheTestCases CSS snapshots

Update postcss-modules-plugins snapshots reflecting the comma balanced
stack fix (removal of stray ')' in :local() output).
Add missing CSS test snapshots for ConfigCacheTestCases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* update

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
X
Xiao committed
d109a4331da148427e0c5305c9fbd7711fb4b724
Parent: 474b377
Committed by GitHub <noreply@github.com> on 3/16/2026, 3:34:33 PM