Skip to content

fix(css): include chunk groups in conflicting order warning#20660

Merged
alexander-akait merged 5 commits intowebpack:mainfrom
aryanraj45:fix-fresh-css-warning-2
Mar 23, 2026
Merged

fix(css): include chunk groups in conflicting order warning#20660
alexander-akait merged 5 commits intowebpack:mainfrom
aryanraj45:fix-fresh-css-warning-2

Conversation

@aryanraj45
Copy link
Copy Markdown
Contributor

Summary

This pull request resolves an explicit TODO: print better warning inside CssModulesPlugin.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 modulesByChunkGroup collection to filter and append the exact chunk groups causing the conflict directly to the WebpackError.

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.js to strictly assert that the new caused 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

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.
Copilot AI review requested due to automatic review settings March 17, 2026 15:05
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 17, 2026

🦋 Changeset detected

Latest commit: b9b212a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack Patch

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 chunkGroup alongside 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.

Comment thread lib/css/CssModulesPlugin.js Outdated
@aryanraj45
Copy link
Copy Markdown
Contributor Author

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/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we have only one group here? Still looking is unreadable

Comment thread lib/css/CssModulesPlugin.js Outdated
)}\nConflict is caused by the following chunk groups: ${[...conflictingGroups].join(", ")}`
)}\ncaused by chunk group${
groups.length > 1 ? "s" : ""
} ${groups.join(", ")}`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@aryanraj45 aryanraj45 force-pushed the fix-fresh-css-warning-2 branch 2 times, most recently from 8150505 to 169b7cc Compare March 18, 2026 13:13
@aryanraj45
Copy link
Copy Markdown
Contributor Author

@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
Conflicting order between css ./b.css
and css ./c.css
CSS modules are imported in:

  • css ./lazy1.css
  • css ./lazy2.css

Let me know if this looks good.Thanks!

Comment thread lib/css/CssModulesPlugin.js Outdated
}
}
return [...issuers];
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@aryanraj45 aryanraj45 force-pushed the fix-fresh-css-warning-2 branch from 455161f to 0b9890f Compare March 18, 2026 14:11
@aryanraj45
Copy link
Copy Markdown
Contributor Author

@alexander-akait can u please re-review it again i have used the same getincomingconnectionbyoriginmodule for modulegraph extraction

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 21, 2026

Merging this PR will degrade performance by 33.97%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 3 improved benchmarks
❌ 2 regressed benchmarks
✅ 121 untouched benchmarks
⏩ 18 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

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)

Open in CodSpeed

Footnotes

  1. 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.

@aryanraj45
Copy link
Copy Markdown
Contributor Author

@alexander-akait ci all required test passed! Ready for merge thanks!

@alexander-akait alexander-akait merged commit 70867d6 into webpack:main Mar 23, 2026
52 of 55 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

This PR is packaged and the instant preview is available (70867d6).

Install it locally:

  • npm
npm i -D webpack@https://pkg.pr.new/webpack@70867d6
  • yarn
yarn add -D webpack@https://pkg.pr.new/webpack@70867d6
  • pnpm
pnpm add -D webpack@https://pkg.pr.new/webpack@70867d6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants