diff --git a/crates/rspack_plugin_progress/src/lib.rs b/crates/rspack_plugin_progress/src/lib.rs index 42070542bab..692076c4b12 100644 --- a/crates/rspack_plugin_progress/src/lib.rs +++ b/crates/rspack_plugin_progress/src/lib.rs @@ -29,8 +29,9 @@ impl ProgressPlugin { pub fn new(options: ProgressPluginOptions) -> Self { let progress_bar = ProgressBar::with_draw_target(Some(100), ProgressDrawTarget::stdout()); progress_bar.set_style( - ProgressStyle::with_template("{prefix} {bar:40.cyan/blue} {percent}% {wide_msg}") - .expect("TODO:"), + ProgressStyle::with_template("{prefix:.bold} {bar:25.green/white.dim} {wide_msg:.dim}") + .expect("TODO:") + .progress_chars("━━"), ); Self { options, @@ -84,14 +85,21 @@ impl Plugin for ProgressPlugin { async fn succeed_module(&self, _module: &dyn Module) -> Result<()> { let previous_modules_done = self.modules_done.fetch_add(1, SeqCst); let modules_done = previous_modules_done + 1; + + // Assume a minimum of 200 modules to avoid progress growing too quickly + let min_total_module: u32 = 200; + let percent = (modules_done as f32) / (cmp::max( - self.last_modules_count.read().expect("TODO:").unwrap_or(1), - self.modules_count.load(SeqCst), + cmp::max( + self.last_modules_count.read().expect("TODO:").unwrap_or(1), + self.modules_count.load(SeqCst), + ), + min_total_module, ) as f32); self .progress_bar - .set_position((10.0 + 55.0 * percent) as u64); + .set_position((10.0 + 65.0 * percent) as u64); Ok(()) } diff --git a/packages/rspack/src/stats/DefaultStatsPrinterPlugin.ts b/packages/rspack/src/stats/DefaultStatsPrinterPlugin.ts index 6e50b374276..bc220ef7aa0 100644 --- a/packages/rspack/src/stats/DefaultStatsPrinterPlugin.ts +++ b/packages/rspack/src/stats/DefaultStatsPrinterPlugin.ts @@ -105,7 +105,7 @@ const SIMPLE_PRINTERS: Record< const builtAtMessage = root && builtAt ? `${formatDateTime(builtAt)}: ` : ""; const versionMessage = - root && rspackVersion ? `rspack ${rspackVersion}` : ""; + root && rspackVersion ? `Rspack ${rspackVersion}` : ""; const nameMessage = root && name ? bold(name) @@ -117,7 +117,7 @@ const SIMPLE_PRINTERS: Record< const subjectMessage = nameMessage && versionMessage ? `${nameMessage} (${versionMessage})` - : versionMessage || nameMessage || "rspack"; + : versionMessage || nameMessage || "Rspack"; let statusMessage; if (errorsMessage && warningsMessage) { statusMessage = `compiled with ${errorsMessage} and ${warningsMessage}`; diff --git a/packages/rspack/tests/Stats.test.ts b/packages/rspack/tests/Stats.test.ts index e137424c586..fceedfa6fb0 100644 --- a/packages/rspack/tests/Stats.test.ts +++ b/packages/rspack/tests/Stats.test.ts @@ -34,7 +34,7 @@ describe("Stats", () => { entry ./fixtures/a ./fixtures/a.js [876] {main} entry ./fixtures/a - rspack compiled successfully (224575f0bba4bc71b95f)" + Rspack compiled successfully (224575f0bba4bc71b95f)" `); }); @@ -79,7 +79,7 @@ describe("Stats", () => { - rspack compiled with 1 error (51da9544767033575b9e)" + Rspack compiled with 1 error (51da9544767033575b9e)" `); }); diff --git a/packages/rspack/tests/__snapshots__/StatsTestCases.test.ts.snap b/packages/rspack/tests/__snapshots__/StatsTestCases.test.ts.snap index f6c1b02346c..dcfd6a96118 100644 --- a/packages/rspack/tests/__snapshots__/StatsTestCases.test.ts.snap +++ b/packages/rspack/tests/__snapshots__/StatsTestCases.test.ts.snap @@ -337,7 +337,7 @@ chunk {main} bundle.js (main) [entry] entry ./index ./stringModule.js [363] {main} esm import ./stringModule [10] -rspack compiled successfully (7a935a9f14af6fedd836)" +Rspack compiled successfully (7a935a9f14af6fedd836)" `; exports[`StatsTestCases should print correct stats for filename 1`] = ` @@ -602,7 +602,7 @@ chunk {main} main.xxxx.js (main) >{dynamic_js}< [entry] entry ./index ./dynamic.js [426] {dynamic_js} dynamic import ./dynamic [10] -rspack compiled successfully (6d7c52e50cefca7d30c4)" +Rspack compiled successfully (6d7c52e50cefca7d30c4)" `; exports[`StatsTestCases should print correct stats for hot+production 1`] = ` @@ -760,7 +760,7 @@ chunk {main} bundle.js (main) [entry] entry ./index.js ./index.js [10] {main} entry ./index.js -rspack compiled successfully (8b17e56c72949ef15048)" +Rspack compiled successfully (8b17e56c72949ef15048)" `; exports[`StatsTestCases should print correct stats for identifier-let-strict-mode 1`] = ` @@ -817,7 +817,7 @@ error[javascript]: JavaScript parsing error -rspack compiled with 2 errors" +Rspack compiled with 2 errors" `; exports[`StatsTestCases should print correct stats for ignore-plugin 1`] = ` @@ -929,7 +929,7 @@ exports[`StatsTestCases should print correct stats for ignore-warning 1`] = ` } `; -exports[`StatsTestCases should print correct stats for ignore-warning 2`] = `"rspack compiled successfully"`; +exports[`StatsTestCases should print correct stats for ignore-warning 2`] = `"Rspack compiled successfully"`; exports[`StatsTestCases should print correct stats for issue-3558 1`] = ` { @@ -941,7 +941,7 @@ exports[`StatsTestCases should print correct stats for issue-3558 1`] = ` } `; -exports[`StatsTestCases should print correct stats for issue-3558 2`] = `"rspack compiled successfully"`; +exports[`StatsTestCases should print correct stats for issue-3558 2`] = `"Rspack compiled successfully"`; exports[`StatsTestCases should print correct stats for legacy-ie-css-warning 1`] = ` { @@ -953,7 +953,7 @@ exports[`StatsTestCases should print correct stats for legacy-ie-css-warning 1`] } `; -exports[`StatsTestCases should print correct stats for legacy-ie-css-warning 2`] = `"rspack compiled successfully"`; +exports[`StatsTestCases should print correct stats for legacy-ie-css-warning 2`] = `"Rspack compiled successfully"`; exports[`StatsTestCases should print correct stats for loader-builtin-swc-plugin-warn 1`] = ` { @@ -977,7 +977,7 @@ exports[`StatsTestCases should print correct stats for loader-builtin-swc-plugin -rspack compiled with 1 warning" +Rspack compiled with 1 warning" `; exports[`StatsTestCases should print correct stats for logging 1`] = ` @@ -1066,7 +1066,7 @@ exports[`StatsTestCases should print correct stats for minify-error-recovery 2`] -rspack compiled with 1 error" +Rspack compiled with 1 error" `; exports[`StatsTestCases should print correct stats for named-chunk-group 1`] = ` @@ -1155,7 +1155,7 @@ exports[`StatsTestCases should print correct stats for normal-errors 2`] = ` -rspack compiled with 1 error" +Rspack compiled with 1 error" `; exports[`StatsTestCases should print correct stats for optimization-runtime-chunk 1`] = ` @@ -1771,7 +1771,7 @@ exports[`StatsTestCases should print correct stats for parse-error 2`] = ` -rspack compiled with 1 error" +Rspack compiled with 1 error" `; exports[`StatsTestCases should print correct stats for parse-error-builtin-swc-loader 1`] = ` @@ -1815,7 +1815,7 @@ exports[`StatsTestCases should print correct stats for parse-error-builtin-swc-l -rspack compiled with 1 error" +Rspack compiled with 1 error" `; exports[`StatsTestCases should print correct stats for reasons 1`] = ` @@ -2144,7 +2144,7 @@ error[internal]: Resolve error -rspack compiled with 1 error (745b7086c5177811e94a)" +Rspack compiled with 1 error (745b7086c5177811e94a)" `; exports[`StatsTestCases should print correct stats for resolve-unexpected-exports-in-pkg 1`] = ` @@ -2403,7 +2403,7 @@ error[internal]: Export should be relative path and start with "./", but got ../ -rspack compiled with 1 error (4e3ebc05601fcb8c4e16)" +Rspack compiled with 1 error (4e3ebc05601fcb8c4e16)" `; exports[`StatsTestCases should print correct stats for simple 1`] = ` @@ -2561,7 +2561,7 @@ chunk {main} bundle.js (main) [entry] entry ./index ./index.js [10] {main} entry ./index -rspack compiled successfully (96a5acbdbd5061c8e5ac)" +Rspack compiled successfully (96a5acbdbd5061c8e5ac)" `; exports[`StatsTestCases should print correct stats for simple-module-source 1`] = ` @@ -2849,7 +2849,7 @@ Entrypoint main 631 bytes = bundle.js ./raw.png ./index.js ./stringModule.js -rspack compiled successfully (58ffc7a5ede4848a7209)" +Rspack compiled successfully (58ffc7a5ede4848a7209)" `; exports[`StatsTestCases should print correct stats for stats-hooks 1`] = ` @@ -3000,7 +3000,7 @@ exports[`StatsTestCases should print correct stats for stats-hooks 2`] = ` asset bundle.js 589 bytes [emitted111] (name: main) [testA: aaaaaa] Entrypoint main 589 bytes = bundle.js ./index.js -rspack compiled successfully (96a5acbdbd5061c8e5ac)" +Rspack compiled successfully (96a5acbdbd5061c8e5ac)" `; exports[`StatsTestCases should print correct stats for try-require--module 1`] = ` @@ -3045,7 +3045,7 @@ exports[`StatsTestCases should print correct stats for try-require--module 2`] = -rspack compiled with 1 warning" +Rspack compiled with 1 warning" `; exports[`StatsTestCases should print correct stats for try-require-resolve-module 1`] = ` @@ -3090,7 +3090,7 @@ exports[`StatsTestCases should print correct stats for try-require-resolve-modul -rspack compiled with 1 warning" +Rspack compiled with 1 warning" `; exports[`StatsTestCases should print correct stats for try-require-resolve-weak-module 1`] = ` @@ -3135,5 +3135,5 @@ exports[`StatsTestCases should print correct stats for try-require-resolve-weak- -rspack compiled with 1 warning" +Rspack compiled with 1 warning" `;