Skip to content

Use root package suffix in clean log messages #7648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
#### :bug: Bug fix

- Fix `typeof` parens on functions. https://github.com/rescript-lang/rescript/pull/7643
- Add --dev flag to clean command. https://github.com/rescript-lang/rescript/pull/7622
- Rewatch: Add --dev flag to clean command. https://github.com/rescript-lang/rescript/pull/7622
- Rewatch: Use root package suffix in clean log messages. https://github.com/rescript-lang/rescript/pull/7648

# 12.0.0-beta.1

Expand Down
33 changes: 21 additions & 12 deletions rewatch/src/build/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,14 @@ pub fn remove_compile_assets(package: &packages::Package, source_file: &Path) {
}
}

pub fn clean_mjs_files(build_state: &BuildState) {
fn clean_source_files(build_state: &BuildState, root_package: &packages::Package) {
// get all rescript file locations
let rescript_file_locations = build_state
.modules
.values()
.filter_map(|module| match &module.source_type {
SourceType::SourceFile(source_file) => {
let package = build_state.packages.get(&module.package_name).unwrap();
let root_package = build_state
.packages
.get(&build_state.root_config_name)
.expect("Could not find root package");

Some(
root_package
.config
Expand Down Expand Up @@ -391,10 +386,6 @@ pub fn clean(path: &Path, show_progress: bool, snapshot_output: bool, build_dev_
}

let timing_clean_mjs = Instant::now();
if !snapshot_output && show_progress {
println!("{} {}Cleaning mjs files...", style("[2/2]").bold().dim(), SWEEP);
let _ = std::io::stdout().flush();
}
let mut build_state = BuildState::new(
project_root.to_owned(),
root_config_name,
Expand All @@ -403,15 +394,33 @@ pub fn clean(path: &Path, show_progress: bool, snapshot_output: bool, build_dev_
bsc_path,
);
packages::parse_packages(&mut build_state);
clean_mjs_files(&build_state);
let root_package = build_state
.packages
.get(&build_state.root_config_name)
.expect("Could not find root package");

let suffix = root_package.config.suffix.as_deref().unwrap_or(".res.mjs");

if !snapshot_output && show_progress {
println!(
"{} {}Cleaning {} files...",
style("[2/2]").bold().dim(),
SWEEP,
suffix
);
let _ = std::io::stdout().flush();
}

clean_source_files(&build_state, root_package);
let timing_clean_mjs_elapsed = timing_clean_mjs.elapsed();

if !snapshot_output && show_progress {
println!(
"{}{} {}Cleaned mjs files in {:.2}s",
"{}{} {}Cleaned {} files in {:.2}s",
LINE_CLEAR,
style("[2/2]").bold().dim(),
SWEEP,
suffix,
timing_clean_mjs_elapsed.as_secs_f64()
);
let _ = std::io::stdout().flush();
Expand Down
2 changes: 1 addition & 1 deletion rewatch/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ pub fn get_bsc() -> PathBuf {

bsc_path
.canonicalize()
.expect("Could not get bsc path")
.expect("Could not get bsc path, did you set environment variable RESCRIPT_BSC_EXE ?")
.to_stripped_verbatim_path()
}

Expand Down