Skip to content

Commit 65c599f

Browse files
authored
fix: ignore warning config for non local deps (#7614)
* fix: ignore warning config for non local deps * chore: changelog
1 parent d70c7fa commit 65c599f

File tree

5 files changed

+39
-27
lines changed

5 files changed

+39
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
- Pass location to children prop in jsx ppx. https://github.com/rescript-lang/rescript/pull/7540
4848
- Fix crash when `bs-g` is used with untagged variants. https://github.com/rescript-lang/rescript/pull/7575
4949
- Fix issue with preserve mode where `jsx` is declared as an external without a `@module` attribute. https://github.com/rescript-lang/rescript/pull/7591
50+
- Fix rewatch considering warning configs of non-local dependencies. https://github.com/rescript-lang/rescript/pull/7614
5051

5152
#### :nail_care: Polish
5253

rewatch/src/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ pub fn get_compiler_args(
114114
&workspace_root,
115115
&None,
116116
build_dev_deps,
117+
true,
117118
);
118119

119120
let result = serde_json::to_string_pretty(&CompilerArgs {

rewatch/src/build/compile.rs

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ pub fn compiler_args(
364364
// this saves us a scan to find their paths
365365
packages: &Option<&AHashMap<String, packages::Package>>,
366366
build_dev_deps: bool,
367+
is_local_dep: bool,
367368
) -> Vec<String> {
368369
let bsc_flags = config::flatten_flags(&config.bsc_flags);
369370

@@ -399,30 +400,7 @@ pub fn compiler_args(
399400
let jsx_mode_args = root_config.get_jsx_mode_args();
400401
let jsx_preserve_args = root_config.get_jsx_preserve_args();
401402
let gentype_arg = config.get_gentype_arg();
402-
403-
let warning_args: Vec<String> = match config.warnings.to_owned() {
404-
None => vec![],
405-
Some(warnings) => {
406-
let warn_number = match warnings.number {
407-
None => vec![],
408-
Some(warnings) => {
409-
vec!["-w".to_string(), warnings.to_string()]
410-
}
411-
};
412-
413-
let warn_error = match warnings.error {
414-
Some(config::Error::Catchall(true)) => {
415-
vec!["-warn-error".to_string(), "A".to_string()]
416-
}
417-
Some(config::Error::Qualified(errors)) => {
418-
vec!["-warn-error".to_string(), errors.to_string()]
419-
}
420-
_ => vec![],
421-
};
422-
423-
[warn_number, warn_error].concat()
424-
}
425-
};
403+
let warning_args = config.get_warning_args(is_local_dep);
426404

427405
let read_cmi_args = match has_interface {
428406
true => {
@@ -624,6 +602,7 @@ fn compile_file(
624602
workspace_root,
625603
&Some(packages),
626604
build_dev_deps,
605+
package.is_local_dep,
627606
);
628607

629608
let to_mjs = Command::new(bsc_path)
@@ -778,7 +757,7 @@ fn compile_file(
778757

779758
if helpers::contains_ascii_characters(&err) {
780759
if package.is_pinned_dep || package.is_local_dep {
781-
// supress warnings of external deps
760+
// suppress warnings of external deps
782761
Ok(Some(err))
783762
} else {
784763
Ok(None)

rewatch/src/build/packages.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ pub fn read_dependency(
287287
/// Given a config, recursively finds all dependencies.
288288
/// 1. It starts with registering dependencies and
289289
/// prevents the operation for the ones which are already
290-
/// registerd for the parent packages. Especially relevant for peerDependencies.
290+
/// registered for the parent packages. Especially relevant for peerDependencies.
291291
/// 2. In parallel performs IO to read the dependencies config and
292292
/// recursively continues operation for their dependencies as well.
293293
fn read_dependencies(
@@ -329,7 +329,7 @@ fn read_dependencies(
329329

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

335335
std::process::exit(2)

rewatch/src/config.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,37 @@ impl Config {
470470
}
471471
}
472472

473+
pub fn get_warning_args(&self, is_local_dep: bool) -> Vec<String> {
474+
// Ignore warning config for non local dependencies (node_module dependencies)
475+
if !is_local_dep {
476+
return vec![];
477+
}
478+
479+
match self.warnings {
480+
None => vec![],
481+
Some(ref warnings) => {
482+
let warn_number = match warnings.number {
483+
None => vec![],
484+
Some(ref warnings) => {
485+
vec!["-w".to_string(), warnings.to_string()]
486+
}
487+
};
488+
489+
let warn_error = match warnings.error {
490+
Some(Error::Catchall(true)) => {
491+
vec!["-warn-error".to_string(), "A".to_string()]
492+
}
493+
Some(Error::Qualified(ref errors)) => {
494+
vec!["-warn-error".to_string(), errors.to_string()]
495+
}
496+
_ => vec![],
497+
};
498+
499+
[warn_number, warn_error].concat()
500+
}
501+
}
502+
}
503+
473504
pub fn get_package_specs(&self) -> Vec<PackageSpec> {
474505
match self.package_specs.clone() {
475506
None => vec![PackageSpec {

0 commit comments

Comments
 (0)