8000 test: refactor watchTestCase when ESM by hai-x · Pull Request #19571 · webpack/webpack · GitHub
[go: up one dir, main page]

Skip to content

test: refactor watchTestCase when ESM #19571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2025

Conversation

hai-x
Copy link
Member
@hai-x hai-x commented May 30, 2025

What kind of change does this PR introduce?

We should clean the output directory before the second compilation starts. Otherwise, we will execute all output files generated from previous compilations, especially when they have different content hashes. This can lead to the execution of redundant files and also cause potential ESM errors.

For more details, I will outline the files in the output directory and the files being executed:

First Compilation:

Output files: 
- a.hash0.js
- b.hash0.js

Executed files: 
- a.hash0.js
- b.hash0.js

Second Compilation (when the b file remains unchanged):

Output files: 
- a.hash0.js
- a.hash1.js
- b.hash0.js

Executed files: 
- a.hash0.js
- a.hash1.js
- b.hash0.js

What we expected behavior in second compilation :

Output files: 
- a.hash1.js
- b.hash0.js

Executed files: 
- a.hash1.js
- b.hash0.js

So when both a.hash0.js and a.hash1.js import b.hash0.js, this results in multiple links to the same module, causing an ESM error => Module status must be unlinked

Did you add tests for your changes?

Exists

Does this PR introduce a breaking change?

No

What needs to be documented once your changes are merged?

No

@@ -360,29 +362,27 @@ const describeCases = config => {
if (esmMode === "unlinked") return esm;
return (async () => {
if (esmMode === "unlinked") return esm;
if (esm.status !== "evaluated") {
Copy link
Member Author

Choose a reason for hiding this comment

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

The diff may be unreadable. And here i just delete if (esm.status !== "evaluated") {.

Copy link
codspeed-hq bot commented May 30, 2025

CodSpeed Performance Report

Merging #19571 will degrade performances by 73.3%

Comparing hai-x:watch-test-refactor (792918b) with main (e805dc1)

Summary

⚡ 80 improvements
❌ 2 regressions
✅ 51 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}' 11.3 ms 42.5 ms -73.3%
benchmark "future-defaults", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 52.1 ms 10.4 ms ×5
benchmark "minimal", scenario '{"name":"mode-development","mode":"development"}' 24.2 ms 30.4 ms -20.43%
md4 buffer benchmark (size: 10000) 114.1 µs 73 µs +56.31%
md4 buffer benchmark (size: 100000) 447.7 µs 406.7 µs +10.08%
md4 buffer benchmark (size: 120) 76 µs 34.9 µs ×2.2
md4 buffer benchmark (size: 160) 76 µs 35 µs ×2.2
md4 buffer benchmark (size: 16366) 138.4 µs 97.4 µs +42.14%
md4 buffer benchmark (size: 16368) 138.5 µs 97.4 µs +42.2%
md4 buffer benchmark (size: 16370) 138.5 µs 97.5 µs +42.12%
md4 buffer benchmark (size: 2) 76.3 µs 35.1 µs ×2.2
md4 buffer benchmark (size: 20) 76.2 µs 32.7 µs ×2.3
md4 buffer benchmark (size: 200) 76.2 µs 35.2 µs ×2.2
md4 buffer benchmark (size: 2000) 81.8 µs 40.8 µs ×2
md4 buffer benchmark (size: 20000) 152.6 µs 111.6 µs +36.75%
md4 buffer benchmark (size: 2002) 81.8 µs 40.8 µs ×2
md4 buffer benchmark (size: 40) 73.5 µs 32.6 µs ×2.3
md4 buffer benchmark (size: 400) 77 µs 36 µs ×2.1
md4 buffer benchmark (size: 40000) 228.8 µs 187.9 µs +21.77%
md4 buffer benchmark (size: 65536) 327.3 µs 286.2 µs +14.37%
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

@alexander-akait alexander-akait merged commit 79b3000 into webpack:main Jun 1, 2025
43 of 44 checks passed
@hai-x hai-x deleted the watch-test-refactor branch June 1, 2025 15:24
3ru pushed a commit to 3ru/webpack that referenced this pull request Jul 1, 2025
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.

2 participants
0