diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e65eeebdb..69b47a665c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/rewatch/src/build.rs b/rewatch/src/build.rs index 03087a4a83..dc844a8092 100644 --- a/rewatch/src/build.rs +++ b/rewatch/src/build.rs @@ -114,6 +114,7 @@ pub fn get_compiler_args( &workspace_root, &None, build_dev_deps, + true, ); let result = serde_json::to_string_pretty(&CompilerArgs { diff --git a/rewatch/src/build/compile.rs b/rewatch/src/build/compile.rs index b36f006100..8a472e7d85 100644 --- a/rewatch/src/build/compile.rs +++ b/rewatch/src/build/compile.rs @@ -364,6 +364,7 @@ pub fn compiler_args( // this saves us a scan to find their paths packages: &Option<&AHashMap>, build_dev_deps: bool, + is_local_dep: bool, ) -> Vec { let bsc_flags = config::flatten_flags(&config.bsc_flags); @@ -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 = 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 => { @@ -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) @@ -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) diff --git a/rewatch/src/build/packages.rs b/rewatch/src/build/packages.rs index 0b0294d3c9..9783f2b3a6 100644 --- a/rewatch/src/build/packages.rs +++ b/rewatch/src/build/packages.rs @@ -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( @@ -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) diff --git a/rewatch/src/config.rs b/rewatch/src/config.rs index 108762540a..2592509b4b 100644 --- a/rewatch/src/config.rs +++ b/rewatch/src/config.rs @@ -470,6 +470,37 @@ impl Config { } } + pub fn get_warning_args(&self, is_local_dep: bool) -> Vec { + // 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 { match self.package_specs.clone() { None => vec![PackageSpec {