Skip to content

Commit

Permalink
chore(core): Optimization of compilation duration unit (#4264)
Browse files Browse the repository at this point in the history
* Update DefaultStatsPrinterPlugin.ts

* Update DefaultStatsPrinterPlugin.ts
  • Loading branch information
cunzaizhuyi authored Oct 8, 2023
1 parent 07249dd commit d9952e8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/rspack/src/stats/DefaultStatsPrinterPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ const AVAILABLE_FORMATS: Pick_FORMAT<
{ timeReference, bold, green, yellow, red },
boldQuantity
) => {
const unit = " ms";
let unit = " ms";
if (timeReference && time !== timeReference) {
const times = [
timeReference / 2,
Expand All @@ -1244,7 +1244,12 @@ const AVAILABLE_FORMATS: Pick_FORMAT<
else if (time < times[0]) return yellow(`${time}${unit}`);
else return red(`${time}${unit}`);
} else {
return `${boldQuantity ? bold(time.toString()) : time}${unit}`;
let timeStr = time.toString();
if (time > 1000) {
timeStr = `${(time / 1000).toFixed(2)}`;
unit = ' s';
}
return `${boldQuantity ? bold(timeStr) : timeStr}${unit}`;
}
},
formatError: (msg, { green, yellow, red }) => {
Expand Down

0 comments on commit d9952e8

Please sign in to comment.