Skip to content

Commit 00f4c81

Browse files
erasermengstephencookdev
authored andcommitted
feat: add loaderFiles options
1 parent 6de89df commit 00f4c81

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ module.exports = class SpeedMeasurePlugin {
8282
if (typeof this.options.outputFormat === "function")
8383
return this.options.outputFormat(outputObj);
8484
return getHumanOutput(outputObj, {
85+
...this.options,
8586
verbose: this.options.outputFormat === "humanVerbose",
8687
});
8788
}

output.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ module.exports.getHumanOutput = (outputObj, options = {}) => {
9494

9595
xEqualsY.push(["module count", loaderObj.averages.dataPoints]);
9696

97+
if (options.loaderTopFiles) {
98+
const loopLen = Math.min(loaderObj.rawStartEnds.length, options.loaderTopFiles);
99+
for (let i = 0; i < loopLen; i++) {
100+
const rawItem = loaderObj.rawStartEnds[i];
101+
xEqualsY.push([rawItem.name, hT(rawItem.end - rawItem.start)]);
102+
}
103+
}
104+
97105
const maxXLength = xEqualsY.reduce(
98106
(acc, cur) => Math.max(acc, cur[0].length),
99107
0
@@ -148,6 +156,9 @@ module.exports.getLoadersOutput = data => {
148156
activeTime,
149157
loaders: startEnds[0].loaders,
150158
subLoadersTime: subLoadersActiveTime,
159+
rawStartEnds: startEnds.sort(
160+
(a, b) => b.end - b.start - (a.end - a.start)
161+
),
151162
};
152163
});
153164

0 commit comments

Comments
 (0)