Skip to content

fix: fix conflicts caused by multiple concatenateModules#19861

Merged
alexander-akait merged 3 commits intowebpack:mainfrom
xiaoxiaojx:fix/multi-concatenate-modules-named-import-externals
Sep 1, 2025
Merged

fix: fix conflicts caused by multiple concatenateModules#19861
alexander-akait merged 3 commits intowebpack:mainfrom
xiaoxiaojx:fix/multi-concatenate-modules-named-import-externals

Conversation

@xiaoxiaojx
Copy link
Copy Markdown
Member

What kind of change does this PR introduce?
Fixes #19641 (comment)

Did you add tests for your changes?
Yes

Does this PR introduce a breaking change?
No

What needs to be documented once your changes are merged?
No

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Aug 31, 2025

CodSpeed Performance Report

Merging #19861 will degrade performances by 43.07%

Comparing xiaoxiaojx:fix/multi-concatenate-modules-named-import-externals (f125da7) with main (47f9786)

Summary

⚡ 3 improvements
❌ 2 regressions
✅ 37 untouched benchmarks

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

Benchmarks breakdown

Benchmark BASE HEAD Change
benchmark "devtool-eval", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 65.3 ms 114.8 ms -43.07%
benchmark "devtool-source-map", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 45 ms 75.7 ms -40.61%
benchmark "many-chunks-commonjs", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 147.2 ms 106.4 ms +38.25%
benchmark "many-chunks-esm", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 136.3 ms 98.2 ms +38.82%
benchmark "react", scenario '{"name":"mode-development","mode":"development"}' 251.5 ms 183.5 ms +37.05%

@JSerFeng
Copy link
Copy Markdown
Contributor

I don't know if render order of modules is stable in webpack, if modules a,b and c render order changes, the output changes.

@alexander-akait alexander-akait merged commit 6292491 into webpack:main Sep 1, 2025
80 of 82 checks passed
@xiaoxiaojx
Copy link
Copy Markdown
Member Author

@JSerFeng We’ve confirmed that webpack doesn’t have a render order stability issue. The PR has been merged — thanks for reporting the issue and suggesting the fix.

@JSerFeng
Copy link
Copy Markdown
Contributor

JSerFeng commented Sep 2, 2025

It can be unstable, I've created a repro which contains async loaders.

The order of compilation.modules is determined by the factorize order, so if there are async loaders, the order can be unstable, even if webpack main process is single-threaded and iterate order of HashSet in JavaScript is stable.

image

@JSerFeng
Copy link
Copy Markdown
Contributor

JSerFeng commented Sep 2, 2025

The repro here, https://github.com/JSerFeng/webpack-unstable-order-repro/tree/main, you can switching comments in loader.js to simulate async loaders

@xiaoxiaojx
Copy link
Copy Markdown
Member Author

@JSerFeng Nice catch — this is an issue as well. Thanks for reporting it.

@JSerFeng
Copy link
Copy Markdown
Contributor

JSerFeng commented Sep 2, 2025

Rspack does not fix this because we render modules totally in parallel, and before render we can't get any information of modules' usedNames, it's hard to fix it nicely for us.

For webpack, it's single-threaded (for now), you can sort modules first before render

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