Skip to content

fix: ignore warning config for non local deps #7614

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 2 commits into from
Jul 9, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
- Pass location to children prop in jsx ppx. https://github.com/rescript-lang/rescript/pull/7540
- Fix crash when `bs-g` is used with untagged variants. https://github.com/rescript-lang/rescript/pull/7575
- Fix issue with preserve mode where `jsx` is declared as an external without a `@module` attribute. https://github.com/rescript-lang/rescript/pull/7591
- Fix rewatch considering warning configs of non-local dependencies. https://github.com/rescript-lang/rescript/pull/7614

#### :nail_care: Polish

Expand Down
1 change: 1 addition & 0 deletions rewatch/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ pub fn get_compiler_args(
&workspace_root,
&None,
build_dev_deps,
true,
);

let result = serde_json::to_string_pretty(&CompilerArgs {
Expand Down
29 changes: 4 additions & 25 deletions rewatch/src/build/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ pub fn compiler_args(
// this saves us a scan to find their paths
packages: &Option<&AHashMap<String, packages::Package>>,
build_dev_deps: bool,
is_local_dep: bool,
) -> Vec<String> {
let bsc_flags = config::flatten_flags(&config.bsc_flags);

Expand Down Expand Up @@ -399,30 +400,7 @@ pub fn compiler_args(
let jsx_mode_args = root_config.get_jsx_mode_args();
let jsx_preserve_args = root_config.get_jsx_preserve_args();
let gentype_arg = config.get_gentype_arg();

let warning_args: Vec<String> = match config.warnings.to_owned() {
None => vec![],
Some(warnings) => {
let warn_number = match warnings.number {
None => vec![],
Some(warnings) => {
vec!["-w".to_string(), warnings.to_string()]
}
};

let warn_error = match warnings.error {
Some(config::Error::Catchall(true)) => {
vec!["-warn-error".to_string(), "A".to_string()]
}
Some(config::Error::Qualified(errors)) => {
vec!["-warn-error".to_string(), errors.to_string()]
}
_ => vec![],
};

[warn_number, warn_error].concat()
}
};
let warning_args = config.get_warning_args(is_local_dep);

let read_cmi_args = match has_interface {
true => {
Expand Down Expand Up @@ -624,6 +602,7 @@ fn compile_file(
workspace_root,
&Some(packages),
build_dev_deps,
package.is_local_dep,
);

let to_mjs = Command::new(bsc_path)
Expand Down Expand Up @@ -778,7 +757,7 @@ fn compile_file(

if helpers::contains_ascii_characters(&err) {
if package.is_pinned_dep || package.is_local_dep {
// supress warnings of external deps
// suppress warnings of external deps
Ok(Some(err))
} else {
Ok(None)
Expand Down
4 changes: 2 additions & 2 deletions rewatch/src/build/packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ pub fn read_dependency(
/// Given a config, recursively finds all dependencies.
/// 1. It starts with registering dependencies and
/// prevents the operation for the ones which are already
/// registerd for the parent packages. Especially relevant for peerDependencies.
/// registered for the parent packages. Especially relevant for peerDependencies.
/// 2. In parallel performs IO to read the dependencies config and
/// recursively continues operation for their dependencies as well.
fn read_dependencies(
Expand Down Expand Up @@ -329,7 +329,7 @@ fn read_dependencies(

let parent_path_str = parent_path.to_string_lossy();
log::error!(
"We could not build package tree reading depencency '{package_name}', at path '{parent_path_str}'. Error: {error}",
"We could not build package tree reading dependency '{package_name}', at path '{parent_path_str}'. Error: {error}",
);

std::process::exit(2)
Expand Down
31 changes: 31 additions & 0 deletions rewatch/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,37 @@ impl Config {
}
}

pub fn get_warning_args(&self, is_local_dep: bool) -> Vec<String> {
// Ignore warning config for non local dependencies (node_module dependencies)
if !is_local_dep {
return vec![];
}

match self.warnings {
None => vec![],
Some(ref warnings) => {
let warn_number = match warnings.number {
None => vec![],
Some(ref warnings) => {
vec!["-w".to_string(), warnings.to_string()]
}
};

let warn_error = match warnings.error {
Some(Error::Catchall(true)) => {
vec!["-warn-error".to_string(), "A".to_string()]
}
Some(Error::Qualified(ref errors)) => {
vec!["-warn-error".to_string(), errors.to_string()]
}
_ => vec![],
};

[warn_number, warn_error].concat()
}
}
}

pub fn get_package_specs(&self) -> Vec<PackageSpec> {
match self.package_specs.clone() {
None => vec![PackageSpec {
Expand Down