fix(css): include chunk groups in conflicting order warning#20660
fix(css): include chunk groups in conflicting order warning#20660alexander-akait merged 5 commits intowebpack:mainfrom
Conversation
Resolves a TODO in CssModulesPlugin to print a better warning when CSS module imports conflict. It now surfaces the specific chunk groups causing the conflict instead of only printing the conflicting module files. Updates the related diagnostic test to assert this new console output.
🦋 Changeset detectedLatest commit: b9b212a 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 |
There was a problem hiding this comment.
Pull request overview
This PR improves the developer-facing warning emitted by CssModulesPlugin when CSS modules end up in an unresolvable conflicting order across chunk groups, by appending the chunk group(s) involved to the warning text.
Changes:
- Track the originating
chunkGroupalongside each per-chunk-group module ordering list. - Extend the “Conflicting order…” warning message to include
caused by chunk groups .... - Update the config-case warning expectation regex to assert the new message suffix.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/css/CssModulesPlugin.js | Attaches chunk group identifiers to the conflicting-order warning by plumbing chunkGroup through modulesByChunkGroup. |
| test/configCases/css/conflicting-order/warnings.js | Updates the expected warning pattern to include the new caused by chunk groups ... line. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
Hii @alexander-akait can u please take a view on this thanks! |
| module.exports = [ | ||
| [/Conflicting order between css \.\/b\.css and css \.\/c\.css/] | ||
| [ | ||
| /Conflicting order between css \.\/b\.css and css \.\/c\.css\ncaused by chunk groups css, css/ |
There was a problem hiding this comment.
Please test full message, it doesn't look better
| module.exports = [ | ||
| [ | ||
| /Conflicting order between css \.\/b\.css and css \.\/c\.css\ncaused by chunk groups css, css/ | ||
| /Conflicting order between css \.\/b\.css and css \.\/c\.css\nConflict is caused by the following chunk groups: css/ |
There was a problem hiding this comment.
So we have only one group here? Still looking is unreadable
| )}\nConflict is caused by the following chunk groups: ${[...conflictingGroups].join(", ")}` | ||
| )}\ncaused by chunk group${ | ||
| groups.length > 1 ? "s" : "" | ||
| } ${groups.join(", ")}` |
There was a problem hiding this comment.
Sorry, adding s or , is not fixing the unreadable problem, we should improve it by writing understandable error message, what is chunk group css? I know, you may know, but developers will not know, better error message is when you understand where and which modules are conflict
8150505 to
169b7cc
Compare
|
@alexander-akait can u please take a view again I have Updated the warning to show the actual files that imported the conflicting CSS instead of chunk group names. Now outputs would be something like this
Let me know if this looks good.Thanks! |
| } | ||
| } | ||
| return [...issuers]; | ||
| }; |
There was a problem hiding this comment.
I feel like it is AI generated code, because we don't use such patterns to make the same things, we have getIncomingConnectionsByOriginModule and more
455161f to
0b9890f
Compare
|
@alexander-akait can u please re-review it again i have used the same getincomingconnectionbyoriginmodule for modulegraph extraction |
Merging this PR will degrade performance by 33.97%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | benchmark "context-commonjs", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
32.9 ms | 41.3 ms | -20.45% |
| ⚡ | Memory | benchmark "wasm-modules-sync", scenario '{"name":"mode-production","mode":"production"}' |
7.6 MB | 6.2 MB | +22.96% |
| ⚡ | Memory | benchmark "context-esm", scenario '{"name":"mode-production","mode":"production"}' |
10.5 MB | 8.7 MB | +20.3% |
| ❌ | Memory | benchmark "asset-modules-source", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
265.9 KB | 402.7 KB | -33.97% |
| ⚡ | Memory | benchmark "many-modules-commonjs", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
520.5 KB | 393.5 KB | +32.27% |
Comparing aryanraj45:fix-fresh-css-warning-2 (b9b212a) with main (a475512)
Footnotes
-
18 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
|
@alexander-akait ci all required test passed! Ready for merge thanks! |
|
This PR is packaged and the instant preview is available (70867d6). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@70867d6
yarn add -D webpack@https://pkg.pr.new/webpack@70867d6
pnpm add -D webpack@https://pkg.pr.new/webpack@70867d6 |
Summary
This pull request resolves an explicit
TODO: print better warninginsideCssModulesPlugin.js.Previously, when two CSS modules imported each other in conflicting orders across different chunk groups, the console warning only printed the names of the two conflicting modules. This left developers guessing which chunk groups were causing the loop.
This change taps into the existing
modulesByChunkGroupcollection to filter and append the exact chunk groups causing the conflict directly to theWebpackError.What kind of change does this PR introduce?
fix / developer experience (DX)
Did you add tests for your changes?
Yes. I updated the existing snapshot regex in
test/configCases/css/conflicting-order/warnings.jsto strictly assert that the newcaused by chunk groups ...message is being correctly generated during the failure loop.Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
No documentation changes needed.
Use of AI
No AI ,Only used in formatting and writing the PR description