From 4ec91aebbfcf89c5f6e81b789990af305a0fa652 Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Sat, 18 Oct 2025 11:05:44 +0200 Subject: [PATCH 1/6] Reduce logs --- rewatch/src/build.rs | 155 +++++++++++-------------------------------- 1 file changed, 37 insertions(+), 118 deletions(-) diff --git a/rewatch/src/build.rs b/rewatch/src/build.rs index e12c121ea3..f141280832 100644 --- a/rewatch/src/build.rs +++ b/rewatch/src/build.rs @@ -24,7 +24,7 @@ use log::log_enabled; use serde::Serialize; use std::fmt; use std::fs::File; -use std::io::{Write, stdout}; +use std::io::Write; use std::path::{Path, PathBuf}; use std::time::{Duration, Instant}; @@ -137,118 +137,47 @@ pub fn initialize_build( let project_context = ProjectContext::new(path)?; let compiler = get_compiler_info(&project_context)?; - if !plain_output && show_progress { - print!("{} {}Building package tree...", style("[1/7]").bold().dim(), TREE); - let _ = stdout().flush(); - } - - let timing_package_tree = Instant::now(); + let timing_clean_start = Instant::now(); let packages = packages::make(filter, &project_context, show_progress)?; - let timing_package_tree_elapsed = timing_package_tree.elapsed(); let compiler_check = verify_compiler_info(&packages, &compiler); + if !packages::validate_packages_dependencies(&packages) { + return Err(anyhow!("Failed to validate package dependencies")); + } + + let mut build_state = BuildCommandState::new(project_context, packages, compiler, warn_error); + packages::parse_packages(&mut build_state); + + let compile_assets_state = read_compile_state::read(&mut build_state)?; + + let (diff_cleanup, total_cleanup) = clean::cleanup_previous_build(&mut build_state, compile_assets_state); + let timing_clean_total = timing_clean_start.elapsed(); + if show_progress { if plain_output { if let CompilerCheckResult::CleanedPackagesDueToCompiler = compiler_check { // Snapshot-friendly output (no progress prefixes or emojis) println!("Cleaned previous build due to compiler update"); } + println!("Cleaned {diff_cleanup}/{total_cleanup}") } else { - println!( - "{}{} {}Built package tree in {:.2}s", - LINE_CLEAR, - style("[1/7]").bold().dim(), - TREE, - default_timing - .unwrap_or(timing_package_tree_elapsed) - .as_secs_f64() - ); if let CompilerCheckResult::CleanedPackagesDueToCompiler = compiler_check { println!( "{}{} {}Cleaned previous build due to compiler update", LINE_CLEAR, - style("[1/7]").bold().dim(), + style("[1/3]").bold().dim(), SWEEP ); } - } - } - - if !packages::validate_packages_dependencies(&packages) { - return Err(anyhow!("Failed to validate package dependencies")); - } - - let timing_source_files = Instant::now(); - - if !plain_output && show_progress { - print!( - "{} {}Finding source files...", - style("[2/7]").bold().dim(), - LOOKING_GLASS - ); - let _ = stdout().flush(); - } - - let mut build_state = BuildCommandState::new(project_context, packages, compiler, warn_error); - packages::parse_packages(&mut build_state); - let timing_source_files_elapsed = timing_source_files.elapsed(); - - if !plain_output && show_progress { - println!( - "{}{} {}Found source files in {:.2}s", - LINE_CLEAR, - style("[2/7]").bold().dim(), - LOOKING_GLASS, - default_timing - .unwrap_or(timing_source_files_elapsed) - .as_secs_f64() - ); - - print!( - "{} {}Reading compile state...", - style("[3/7]").bold().dim(), - COMPILE_STATE - ); - let _ = stdout().flush(); - } - let timing_compile_state = Instant::now(); - let compile_assets_state = read_compile_state::read(&mut build_state)?; - let timing_compile_state_elapsed = timing_compile_state.elapsed(); - - if !plain_output && show_progress { - println!( - "{}{} {}Read compile state {:.2}s", - LINE_CLEAR, - style("[3/7]").bold().dim(), - COMPILE_STATE, - default_timing - .unwrap_or(timing_compile_state_elapsed) - .as_secs_f64() - ); - - print!( - "{} {}Cleaning up previous build...", - style("[4/7]").bold().dim(), - SWEEP - ); - } - let timing_cleanup = Instant::now(); - let (diff_cleanup, total_cleanup) = clean::cleanup_previous_build(&mut build_state, compile_assets_state); - let timing_cleanup_elapsed = timing_cleanup.elapsed(); - - if show_progress { - if plain_output { - println!("Cleaned {diff_cleanup}/{total_cleanup}") - } else { println!( - "{}{} {}Cleaned {}/{} {:.2}s", + "{}{} {}Cleaned {}/{} in {:.2}s", LINE_CLEAR, - style("[4/7]").bold().dim(), + style("[1/3]").bold().dim(), SWEEP, diff_cleanup, total_cleanup, - default_timing.unwrap_or(timing_cleanup_elapsed).as_secs_f64() + default_timing.unwrap_or(timing_clean_total).as_secs_f64() ); } } @@ -316,8 +245,8 @@ pub fn incremental_build( } else { ProgressBar::hidden() }; - let mut current_step = if only_incremental { 1 } else { 5 }; - let total_steps = if only_incremental { 3 } else { 7 }; + let mut current_step = if only_incremental { 1 } else { 2 }; + let total_steps = if only_incremental { 2 } else { 3 }; pb.set_style( ProgressStyle::with_template(&format!( "{} {}Parsing... {{spinner}} {{pos}}/{{len}} {{msg}}", @@ -327,27 +256,14 @@ pub fn incremental_build( .unwrap(), ); + let timing_parse_start = Instant::now(); let timing_ast = Instant::now(); let result_asts = parse::generate_asts(build_state, || pb.inc(1)); let timing_ast_elapsed = timing_ast.elapsed(); match result_asts { Ok(_ast) => { - if show_progress { - if plain_output { - println!("Parsed {num_dirty_modules} source files") - } else { - println!( - "{}{} {}Parsed {} source files in {:.2}s", - LINE_CLEAR, - format_step(current_step, total_steps), - CODE, - num_dirty_modules, - default_timing.unwrap_or(timing_ast_elapsed).as_secs_f64() - ); - pb.finish(); - } - } + pb.finish(); } Err(err) => { logs::finalize(&build_state.packages); @@ -370,20 +286,23 @@ pub fn incremental_build( }); } } - let timing_deps = Instant::now(); let deleted_modules = build_state.deleted_modules.clone(); deps::get_deps(build_state, &deleted_modules); - let timing_deps_elapsed = timing_deps.elapsed(); - current_step += 1; + let timing_parse_total = timing_parse_start.elapsed(); - if !plain_output && show_progress { - println!( - "{}{} {}Collected deps in {:.2}s", - LINE_CLEAR, - format_step(current_step, total_steps), - DEPS, - default_timing.unwrap_or(timing_deps_elapsed).as_secs_f64() - ); + if show_progress { + if plain_output { + println!("Parsed {num_dirty_modules} source files") + } else { + println!( + "{}{} {}Parsed {} source files in {:.2}s", + LINE_CLEAR, + format_step(current_step, total_steps), + CODE, + num_dirty_modules, + default_timing.unwrap_or(timing_parse_total).as_secs_f64() + ); + } } mark_modules_with_expired_deps_dirty(build_state); From 535975ba53c23e4c66541b6da925a3f6b9d1a5e6 Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Sun, 19 Oct 2025 14:29:11 +0200 Subject: [PATCH 2/6] Fix line break --- rewatch/src/build/clean.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rewatch/src/build/clean.rs b/rewatch/src/build/clean.rs index 8d63db7ef6..7c05908ce4 100644 --- a/rewatch/src/build/clean.rs +++ b/rewatch/src/build/clean.rs @@ -391,7 +391,7 @@ pub fn clean(path: &Path, show_progress: bool, plain_output: bool) -> Result<()> }; if !plain_output && show_progress { - println!( + print!( "{} {}Cleaning {} files...", style("[2/2]").bold().dim(), SWEEP, From 21041b87b7437ae223bef419c39afdcc3d702e85 Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Sun, 19 Oct 2025 14:33:49 +0200 Subject: [PATCH 3/6] Removed unused emojis --- rewatch/src/helpers.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/rewatch/src/helpers.rs b/rewatch/src/helpers.rs index 16554c75a3..e269a12784 100644 --- a/rewatch/src/helpers.rs +++ b/rewatch/src/helpers.rs @@ -19,16 +19,12 @@ pub mod deserialize; pub mod emojis { use console::Emoji; pub static COMMAND: Emoji<'_, '_> = Emoji("๐Ÿƒ ", ""); - pub static TREE: Emoji<'_, '_> = Emoji("๐Ÿ“ฆ ", ""); pub static SWEEP: Emoji<'_, '_> = Emoji("๐Ÿงน ", ""); - pub static LOOKING_GLASS: Emoji<'_, '_> = Emoji("๐Ÿ‘€ ", ""); pub static CODE: Emoji<'_, '_> = Emoji("๐Ÿงฑ ", ""); pub static SWORDS: Emoji<'_, '_> = Emoji("๐Ÿคบ ", ""); - pub static DEPS: Emoji<'_, '_> = Emoji("๐ŸŒด ", ""); pub static CHECKMARK: Emoji<'_, '_> = Emoji("โœ… ", ""); pub static CROSS: Emoji<'_, '_> = Emoji("โŒ ", ""); pub static SPARKLES: Emoji<'_, '_> = Emoji("โœจ ", ""); - pub static COMPILE_STATE: Emoji<'_, '_> = Emoji("๐Ÿ“ ", ""); pub static LINE_CLEAR: &str = "\x1b[2K\r"; } From eafa384d973da0aedadb8bbf2560761f0390caea Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Fri, 24 Oct 2025 20:23:19 +0200 Subject: [PATCH 4/6] Fix extension print --- rewatch/src/build/clean.rs | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/rewatch/src/build/clean.rs b/rewatch/src/build/clean.rs index 7c05908ce4..a66a460769 100644 --- a/rewatch/src/build/clean.rs +++ b/rewatch/src/build/clean.rs @@ -367,27 +367,23 @@ pub fn clean(path: &Path, show_progress: bool, plain_output: bool) -> Result<()> let mut build_state = BuildState::new(project_context, packages, compiler_info); packages::parse_packages(&mut build_state); let root_config = build_state.get_root_config(); - let suffix_for_print = if plain_output || !show_progress { - String::new() - } else { - match root_config.package_specs { - None => match &root_config.suffix { - None => String::from(".js"), - Some(suffix) => suffix.clone(), - }, - Some(_) => root_config - .get_package_specs() - .into_iter() - .filter_map(|spec| { - if spec.in_source { - spec.suffix.or_else(|| root_config.suffix.clone()) - } else { - None - } - }) - .collect::>() - .join(", "), - } + let suffix_for_print = match root_config.package_specs { + None => match &root_config.suffix { + None => String::from(".js"), + Some(suffix) => suffix.clone(), + }, + Some(_) => root_config + .get_package_specs() + .into_iter() + .filter_map(|spec| { + if spec.in_source { + spec.suffix.or_else(|| root_config.suffix.clone()) + } else { + None + } + }) + .collect::>() + .join(", "), }; if !plain_output && show_progress { From 977e3c7a9458da3de0b3ef0e977c16422c47a44e Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Fri, 24 Oct 2025 20:28:14 +0200 Subject: [PATCH 5/6] Add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76c76378d5..acae4156e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ - Rewatch: plain output when not running in tty. https://github.com/rescript-lang/rescript/pull/7970 - Streamline rewatch help texts. https://github.com/rescript-lang/rescript/pull/7973 +- Rewatch: Reduced build progress output from 7 steps to 3 for cleaner, less verbose logging #### :house: Internal From 1d2aec3f62a7c1e9031dbccc287b4600ca1c47d2 Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Fri, 24 Oct 2025 21:48:34 +0200 Subject: [PATCH 6/6] Add link --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acae4156e6..f8c9f16320 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ - Rewatch: plain output when not running in tty. https://github.com/rescript-lang/rescript/pull/7970 - Streamline rewatch help texts. https://github.com/rescript-lang/rescript/pull/7973 -- Rewatch: Reduced build progress output from 7 steps to 3 for cleaner, less verbose logging +- Rewatch: Reduced build progress output from 7 steps to 3 for cleaner, less verbose logging. https://github.com/rescript-lang/rescript/pull/7971 #### :house: Internal