Skip to content

Commit

Permalink
Merge pull request #7695 from webpack/bugfix/sort-ids-stats
Browse files Browse the repository at this point in the history
sort ids in Stats numerical
  • Loading branch information
sokra committed Jul 10, 2018
2 parents 1869d8e + 692faf2 commit f95d0f0
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 55 deletions.
14 changes: 10 additions & 4 deletions lib/Stats.js
Expand Up @@ -15,6 +15,12 @@ const optionsOrFallback = (...args) => {
return optionValues.find(optionValue => typeof optionValue !== "undefined");
};

const compareId = (a, b) => {
if (a < b) return -1;
if (a > b) return 1;
return 0;
};

class Stats {
constructor(compilation) {
this.compilation = compilation;
Expand Down Expand Up @@ -543,7 +549,7 @@ class Stats {
}
return obj;
})
.sort((a, b) => a.moduleId - b.moduleId);
.sort(compareId);
}
if (showUsedExports) {
if (module.used === true) {
Expand Down Expand Up @@ -614,9 +620,9 @@ class Stats {
names: chunk.name ? [chunk.name] : [],
files: chunk.files.slice(),
hash: chunk.renderedHash,
siblings: Array.from(siblings).sort(),
parents: Array.from(parents).sort(),
children: Array.from(children).sort(),
siblings: Array.from(siblings).sort(compareId),
parents: Array.from(parents).sort(compareId),
children: Array.from(children).sort(compareId),
childrenByOrder: childIdByOrder
};
if (showChunkModules) {
Expand Down

0 comments on commit f95d0f0

Please sign in to comment.