test: cover @value name overriding scenarios across local and imported definitions#20940
Conversation
When the same local name is imported via multiple `@value foo from "..."` declarations, each reference now resolves through the import that was active at its source position rather than the first matching import dep. The active import's request is captured on `IcssDefinition` at parse time, threaded through `getReexport` into the export/symbol dep value, and used to disambiguate matching `CssIcssImportDependency` instances at template apply time. https://claude.ai/code/session_01TeTv91hjhJs491qv7V9ES1
🦋 Changeset detectedLatest commit: dfe7344 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This PR is packaged and the instant preview is available (feb7f37). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@feb7f37
yarn add -D webpack@https://pkg.pr.new/webpack@feb7f37
pnpm add -D webpack@https://pkg.pr.new/webpack@feb7f37 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #20940 +/- ##
==========================================
- Coverage 91.39% 91.39% -0.01%
==========================================
Files 568 568
Lines 56553 56570 +17
Branches 15043 15048 +5
==========================================
+ Hits 51686 51701 +15
- Misses 4867 4869 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a correctness issue in Webpack’s CSS Modules @value handling: when the same local @value name is imported from multiple modules in the same file, references are now resolved against the import that was in scope at the reference position (source-order), rather than always resolving via the first matching import dependency.
Changes:
- Track the active
@valueimport request at parse-time and propagate it through ICSS symbol/export dependency resolution. - Update ICSS export resolution to select the matching
CssIcssImportDependencyby bothlocalNameandrequest(with fallback). - Add a new config-case test suite covering local overrides, import overrides, aliasing, and chained re-aliasing scenarios.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/configCases/css/css-modules-value-overriding/webpack.config.js | Adds a new css/module config-case to exercise @value override behaviors. |
| test/configCases/css/css-modules-value-overriding/style.module.css | Defines ordered local/imported @value scenarios, including same-name multi-import cases. |
| test/configCases/css/css-modules-value-overriding/index.js | Asserts generated CSS substitutions and exported class renaming for each scenario. |
| test/configCases/css/css-modules-value-overriding/colors-a.module.css | Provides imported @value definitions for the new test. |
| test/configCases/css/css-modules-value-overriding/colors-b.module.css | Provides a second imported @value source to validate same-name import override. |
| lib/dependencies/CssIcssSymbolDependency.js | Adds request to disambiguate same-name imports during symbol replacement and hashing/serialization. |
| lib/dependencies/CssIcssExportDependency.js | Extends reference tuples to optionally carry request and resolves imports using a localName+request lookup. |
| lib/css/CssParser.js | Records the active @value import request in ICSS definitions and emits it on symbol/export deps. |
| .changeset/css-value-import-source-order.md | Documents the fix as a patch-level change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merging this PR will degrade performance by 67.71%
Performance Changes
Comparing Footnotes
|
https://claude.ai/code/session_01TeTv91hjhJs491qv7V9ES1