Skip to content

Commit f95d0f0

Browse files
authored
Merge pull request webpack#7695 from webpack/bugfix/sort-ids-stats
sort ids in Stats numerical
2 parents 1869d8e + 692faf2 commit f95d0f0

File tree

2 files changed

+61
-55
lines changed

2 files changed

+61
-55
lines changed

lib/Stats.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ const optionsOrFallback = (...args) => {
1515
return optionValues.find(optionValue => typeof optionValue !== "undefined");
1616
};
1717

18+
const compareId = (a, b) => {
19+
if (a < b) return -1;
20+
if (a > b) return 1;
21+
return 0;
22+
};
23+
1824
class Stats {
1925
constructor(compilation) {
2026
this.compilation = compilation;
@@ -543,7 +549,7 @@ class Stats {
543549
}
544550
return obj;
545551
})
546-
.sort((a, b) => a.moduleId - b.moduleId);
552+
.sort(compareId);
547553
}
548554
if (showUsedExports) {
549555
if (module.used === true) {
@@ -614,9 +620,9 @@ class Stats {
614620
names: chunk.name ? [chunk.name] : [],
615621
files: chunk.files.slice(),
616622
hash: chunk.renderedHash,
617-
siblings: Array.from(siblings).sort(),
618-
parents: Array.from(parents).sort(),
619-
children: Array.from(children).sort(),
623+
siblings: Array.from(siblings).sort(compareId),
624+
parents: Array.from(parents).sort(compareId),
625+
children: Array.from(children).sort(compareId),
620626
childrenByOrder: childIdByOrder
621627
};
622628
if (showChunkModules) {

0 commit comments

Comments
 (0)