From d9952e8030b0e4d9b31cfcfea7210a024052e80f Mon Sep 17 00:00:00 2001 From: cunzaizhuyi <877824709@qq.com> Date: Sun, 8 Oct 2023 18:35:49 +0800 Subject: [PATCH] chore(core): Optimization of compilation duration unit (#4264) * Update DefaultStatsPrinterPlugin.ts * Update DefaultStatsPrinterPlugin.ts --- packages/rspack/src/stats/DefaultStatsPrinterPlugin.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/rspack/src/stats/DefaultStatsPrinterPlugin.ts b/packages/rspack/src/stats/DefaultStatsPrinterPlugin.ts index bc220ef7aa0..928852896e9 100644 --- a/packages/rspack/src/stats/DefaultStatsPrinterPlugin.ts +++ b/packages/rspack/src/stats/DefaultStatsPrinterPlugin.ts @@ -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, @@ -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 }) => {