Skip to content

fix: Dependency without the sourceOrder attribute must keep their original index#19700

Merged
alexander-akait merged 1 commit intomainfrom
perf/module_order
Jul 14, 2025
Merged

fix: Dependency without the sourceOrder attribute must keep their original index#19700
alexander-akait merged 1 commit intomainfrom
perf/module_order

Conversation

@xiaoxiaojx
Copy link
Member

@xiaoxiaojx xiaoxiaojx commented Jul 14, 2025

What kind of change does this PR introduce?
Fixes #19686

it("dependency without the sourceOrder attribute must keep their original index in the array", () => {
    const deps = [
	    // HarmonyImportSpecifierDependency
	    { name: "b", sourceOrder: 10 },
	    // CommonJSRequireDependency
	    { name: "a" },
	    // CommonJSRequireDependency
	    { name: "d" },
	    // HarmonyImportSpecifierDependency
	    { name: "c", sourceOrder: 5 }
    ];
    
    sortWithSourceOrder(deps, dependencySourceOrderMap);

+   expect(deps.map(d => d.name)).toEqual(["c", "a", "d", "b"]); // ✅
-   expect(deps.map(d => d.name)).toEqual(["c", "b", "a", "d"]); // ❌
});

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

@alexander-akait
Copy link
Member

Looks like tests are failed

@xiaoxiaojx xiaoxiaojx changed the title refactor: code optimization for module dependency sorting fix: Dependency without the sourceOrder attribute must keep their original index Jul 14, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Jul 14, 2025

CodSpeed Performance Report

Merging #19700 will degrade performances by 94.2%

Comparing perf/module_order (cb38daa) with main (d76af00)

Summary

⚡ 80 improvements
❌ 4 regressions
✅ 49 untouched benchmarks

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

Benchmarks breakdown

Benchmark BASE HEAD Change
benchmark "lodash", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 10.3 ms 33.2 ms -69.12%
benchmark "many-modules-esm", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 9.9 ms 47 ms -78.98%
benchmark "minimal", scenario '{"name":"mode-development","mode":"development"}' 24.3 ms 30.6 ms -20.53%
benchmark "three-long", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 13.2 ms 227.6 ms -94.2%
md4 buffer benchmark (size: 10000) 114.5 µs 73.1 µs +56.65%
md4 buffer benchmark (size: 100000) 448 µs 406.8 µs +10.14%
md4 buffer benchmark (size: 120) 76.5 µs 35 µs ×2.2
md4 buffer benchmark (size: 160) 76.4 µs 35.1 µs ×2.2
md4 buffer benchmark (size: 16366) 138.9 µs 97.5 µs +42.49%
md4 buffer benchmark (size: 16368) 138.9 µs 97.6 µs +42.33%
md4 buffer benchmark (size: 16370) 139 µs 97.6 µs +42.5%
md4 buffer benchmark (size: 2) 76.7 µs 35.1 µs ×2.2
md4 buffer benchmark (size: 20) 76.9 µs 32.7 µs ×2.4
md4 buffer benchmark (size: 200) 76.8 µs 35.3 µs ×2.2
md4 buffer benchmark (size: 2000) 82.4 µs 40.9 µs ×2
md4 buffer benchmark (size: 20000) 153.1 µs 111.7 µs +37.07%
md4 buffer benchmark (size: 2002) 82.3 µs 40.8 µs ×2
md4 buffer benchmark (size: 40) 73.9 µs 32.5 µs ×2.3
md4 buffer benchmark (size: 400) 77.5 µs 36 µs ×2.2
md4 buffer benchmark (size: 40000) 229.2 µs 187.9 µs +21.96%
... ... ... ... ...

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

@alexander-akait alexander-akait merged commit fdb0c4e into main Jul 14, 2025
43 of 44 checks passed
@alexander-akait alexander-akait deleted the perf/module_order branch July 14, 2025 16:49
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