diff --git a/rewatch/src/build.rs b/rewatch/src/build.rs index 88394eddda2..612d49eb183 100644 --- a/rewatch/src/build.rs +++ b/rewatch/src/build.rs @@ -436,8 +436,21 @@ pub fn incremental_build( } fn log_config_warnings(build_state: &BuildCommandState) { - build_state.packages.iter().for_each(|(_, package)| { - // Only warn for local dependencies, not external packages + let mut packages: Vec<_> = build_state.packages.values().collect(); + packages.sort_by(|a, b| a.name.cmp(&b.name)); + packages.iter().for_each(|package| { + let deprecations = package.config.get_deprecations(); + if !deprecations.is_empty() { + // External consumers can't fix deprecations themselves, so we + // point them at the package's issue tracker when we can find one. + let issue_tracker_url = if package.is_local_dep { + None + } else { + crate::build::packages::read_issue_tracker_url(&package.path) + }; + log_deprecations(&package.name, deprecations, issue_tracker_url.as_deref()); + } + if package.is_local_dep { package .config @@ -454,6 +467,44 @@ fn log_config_warnings(build_state: &BuildCommandState) { }); } +fn log_deprecations( + package_name: &str, + deprecations: &[crate::config::DeprecationWarning], + issue_tracker_url: Option<&str>, +) { + let mut message = format!( + "Package '{package_name}' uses deprecated config (support will be removed in a future version):" + ); + for deprecation in deprecations { + let line = match deprecation { + crate::config::DeprecationWarning::BsconfigJson => { + " - filename 'bsconfig.json' — rename to 'rescript.json'" + } + crate::config::DeprecationWarning::BsDependencies => { + " - field 'bs-dependencies' — use 'dependencies' instead" + } + crate::config::DeprecationWarning::BsDevDependencies => { + " - field 'bs-dev-dependencies' — use 'dev-dependencies' instead" + } + crate::config::DeprecationWarning::BscFlags => { + " - field 'bsc-flags' — use 'compiler-flags' instead" + } + crate::config::DeprecationWarning::CjsModule => { + " - module 'cjs' in package-specs — use 'commonjs' instead" + } + crate::config::DeprecationWarning::Es6Module => { + " - module 'es6' in package-specs — use 'esmodule' instead" + } + }; + message.push('\n'); + message.push_str(line); + } + if let Some(url) = issue_tracker_url { + message.push_str(&format!("\nPlease report this to the package maintainer: {url}")); + } + eprintln!("\n{}", style(message).yellow()); +} + fn log_unsupported_config_field(package_name: &str, field_name: &str) { let warning = format!( "The field '{field_name}' found in the package config of '{package_name}' is not supported by ReScript 12's new build system." diff --git a/rewatch/src/build/packages.rs b/rewatch/src/build/packages.rs index a936b415f65..f5d16989042 100644 --- a/rewatch/src/build/packages.rs +++ b/rewatch/src/build/packages.rs @@ -246,7 +246,13 @@ fn get_source_dirs(source: config::Source, sub_path: Option) -> AHashSe pub fn read_config(package_dir: &Path) -> Result { let rescript_json_path = package_dir.join("rescript.json"); - Config::new(&rescript_json_path) + let bsconfig_json_path = package_dir.join("bsconfig.json"); + + if rescript_json_path.exists() { + Config::new(&rescript_json_path) + } else { + Config::new(&bsconfig_json_path) + } } pub fn read_dependency( @@ -446,12 +452,52 @@ pub fn read_package_name(package_dir: &Path) -> Result { return Ok(name); } + if let Some(name) = read_name("bsconfig.json")? { + return Ok(name); + } + Err(anyhow!( "No name field found in package.json or rescript.json in {}", package_dir.to_string_lossy() )) } +/// Looks up the best-effort issue tracker URL for a package by reading its +/// package.json, preferring `bugs.url`, then deriving from `repository`. +/// Returns None if no tracker could be inferred. +pub fn read_issue_tracker_url(package_dir: &Path) -> Option { + let contents = fs::read_to_string(package_dir.join("package.json")).ok()?; + let json: serde_json::Value = serde_json::from_str(&contents).ok()?; + + let extract_url = |v: &serde_json::Value| -> Option { + match v { + serde_json::Value::String(s) => Some(s.to_owned()), + serde_json::Value::Object(o) => o.get("url").and_then(|u| u.as_str()).map(String::from), + _ => None, + } + }; + + if let Some(bugs_url) = json.get("bugs").and_then(extract_url) { + return Some(bugs_url); + } + + json.get("repository") + .and_then(extract_url) + .map(|repo| issues_url_from_repository(&repo)) +} + +fn issues_url_from_repository(repo: &str) -> String { + let cleaned = repo.trim_start_matches("git+").trim_end_matches(".git"); + + // npm shorthand (no scheme, no user@): treat as github-style "owner/repo" + if !cleaned.contains("://") && !cleaned.contains('@') { + let path = cleaned.trim_start_matches("github:"); + return format!("https://github.com/{path}/issues"); + } + + format!("{cleaned}/issues") +} + fn make_package( config: config::Config, package_path: &Path, @@ -1042,7 +1088,7 @@ pub fn validate_packages_dependencies(packages: &AHashMap) -> b mod test { use crate::config; - use super::{Namespace, Package, read_package_name}; + use super::{Namespace, Package, read_issue_tracker_url, read_package_name}; use ahash::{AHashMap, AHashSet}; use std::fs; use std::path::PathBuf; @@ -1176,4 +1222,77 @@ mod test { ) ); } + + fn write_pkg_json(dir: &std::path::Path, body: &str) { + fs::write(dir.join("package.json"), body).expect("package.json should be written"); + } + + #[test] + fn issue_tracker_url_prefers_bugs_url_string() { + let temp_dir = TempDir::new().unwrap(); + write_pkg_json( + temp_dir.path(), + r#"{"name":"x","bugs":"https://example.com/issues"}"#, + ); + assert_eq!( + read_issue_tracker_url(temp_dir.path()), + Some("https://example.com/issues".to_string()) + ); + } + + #[test] + fn issue_tracker_url_prefers_bugs_object_url() { + let temp_dir = TempDir::new().unwrap(); + write_pkg_json( + temp_dir.path(), + r#"{"name":"x","bugs":{"url":"https://example.com/report"}}"#, + ); + assert_eq!( + read_issue_tracker_url(temp_dir.path()), + Some("https://example.com/report".to_string()) + ); + } + + #[test] + fn issue_tracker_url_derives_from_repository_git_url() { + let temp_dir = TempDir::new().unwrap(); + write_pkg_json( + temp_dir.path(), + r#"{"name":"x","repository":"git+https://github.com/owner/repo.git"}"#, + ); + assert_eq!( + read_issue_tracker_url(temp_dir.path()), + Some("https://github.com/owner/repo/issues".to_string()) + ); + } + + #[test] + fn issue_tracker_url_derives_from_repository_object() { + let temp_dir = TempDir::new().unwrap(); + write_pkg_json( + temp_dir.path(), + r#"{"name":"x","repository":{"type":"git","url":"https://github.com/owner/repo.git"}}"#, + ); + assert_eq!( + read_issue_tracker_url(temp_dir.path()), + Some("https://github.com/owner/repo/issues".to_string()) + ); + } + + #[test] + fn issue_tracker_url_handles_shorthand() { + let temp_dir = TempDir::new().unwrap(); + write_pkg_json(temp_dir.path(), r#"{"name":"x","repository":"owner/repo"}"#); + assert_eq!( + read_issue_tracker_url(temp_dir.path()), + Some("https://github.com/owner/repo/issues".to_string()) + ); + } + + #[test] + fn issue_tracker_url_returns_none_without_hints() { + let temp_dir = TempDir::new().unwrap(); + write_pkg_json(temp_dir.path(), r#"{"name":"x"}"#); + assert_eq!(read_issue_tracker_url(temp_dir.path()), None); + } } diff --git a/rewatch/src/config.rs b/rewatch/src/config.rs index 1f0ea703489..44c4885695c 100644 --- a/rewatch/src/config.rs +++ b/rewatch/src/config.rs @@ -155,9 +155,9 @@ pub struct PackageSpec { #[derive(Deserialize, Debug, Clone, Eq, PartialEq)] pub enum PackageModule { - #[serde(rename = "commonjs")] + #[serde(rename = "commonjs", alias = "cjs")] CommonJs, - #[serde(rename = "esmodule")] + #[serde(rename = "esmodule", alias = "es6")] EsModule, } @@ -244,7 +244,14 @@ pub struct JsPostBuild { } #[derive(Debug, Clone, Copy, PartialEq, PartialOrd)] -pub enum DeprecationWarning {} +pub enum DeprecationWarning { + BsconfigJson, + BsDependencies, + BsDevDependencies, + BscFlags, + CjsModule, + Es6Module, +} #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub enum ExperimentalFeature { @@ -293,13 +300,14 @@ pub struct Config { pub package_specs: Option>, pub warnings: Option, pub suffix: Option, + #[serde(alias = "bs-dependencies")] pub dependencies: Option>, - #[serde(rename = "dev-dependencies")] + #[serde(rename = "dev-dependencies", alias = "bs-dev-dependencies")] pub dev_dependencies: Option>, #[serde(rename = "ppx-flags")] pub ppx_flags: Option>>, - #[serde(rename = "compiler-flags")] + #[serde(rename = "compiler-flags", alias = "bsc-flags")] pub compiler_flags: Option>>, pub namespace: Option, @@ -459,8 +467,9 @@ impl Config { /// Try to convert a config from a string to a config struct pub fn new_from_json_string(config_str: &str) -> Result { - if let Ok(value) = serde_json::from_str::(config_str) { - validate_package_specs_value(&value)?; + let raw_value = serde_json::from_str::(config_str).ok(); + if let Some(value) = raw_value.as_ref() { + validate_package_specs_value(value)?; } let mut deserializer = serde_json::Deserializer::from_str(config_str); @@ -478,6 +487,29 @@ impl Config { } })?; + if let Some(value) = raw_value.as_ref().and_then(|v| v.as_object()) { + for (raw_key, warning) in [ + ("bs-dependencies", DeprecationWarning::BsDependencies), + ("bs-dev-dependencies", DeprecationWarning::BsDevDependencies), + ("bsc-flags", DeprecationWarning::BscFlags), + ] { + if value.contains_key(raw_key) { + config.deprecation_warnings.push(warning); + } + } + } + + if let Some(value) = raw_value.as_ref() { + for (legacy_module, warning) in [ + ("cjs", DeprecationWarning::CjsModule), + ("es6", DeprecationWarning::Es6Module), + ] { + if uses_module_alias(value, legacy_module) { + config.deprecation_warnings.push(warning); + } + } + } + config.handle_deprecations()?; config.unknown_fields = unknown_fields; @@ -485,6 +517,9 @@ impl Config { } fn set_path(&mut self, path: PathBuf) -> Result<()> { + if path.file_name().and_then(|n| n.to_str()) == Some("bsconfig.json") { + self.deprecation_warnings.push(DeprecationWarning::BsconfigJson); + } self.path = path; Ok(()) } @@ -805,6 +840,19 @@ fn resolve_spec_in_source(spec: &serde_json::Value) -> bool { .unwrap_or(true) } +fn uses_module_alias(value: &serde_json::Value, alias: &str) -> bool { + let specs = match value.get("package-specs") { + Some(specs) => specs, + None => return false, + }; + let spec_has_alias = + |spec: &serde_json::Value| -> bool { spec.get("module").and_then(|m| m.as_str()) == Some(alias) }; + match specs { + serde_json::Value::Array(specs) => specs.iter().any(spec_has_alias), + _ => spec_has_alias(specs), + } +} + fn validate_package_spec_value(value: &serde_json::Value) -> Result<()> { let module = match value.get("module") { Some(module) => module, @@ -817,7 +865,7 @@ fn validate_package_spec_value(value: &serde_json::Value) -> Result<()> { }; match module { - "commonjs" | "esmodule" => Ok(()), + "commonjs" | "cjs" | "esmodule" | "es6" => Ok(()), other => Err(anyhow!( "Module system \"{other}\" is unsupported. Expected \"commonjs\" or \"esmodule\"." )), @@ -1130,6 +1178,31 @@ pub mod tests { assert!(config.get_deprecations().is_empty()); } + #[test] + fn test_bs_dependencies_alias() { + let json = r#" + { + "name": "testrepo", + "sources": { + "dir": "src", + "subdirs": true + }, + "package-specs": [ + { + "module": "esmodule", + "in-source": true + } + ], + "suffix": ".mjs", + "bs-dependencies": [ "@testrepo/main" ] + } + "#; + + let config = Config::new_from_json_string(json).expect("a valid json string"); + assert_eq!(config.dependencies, Some(vec!["@testrepo/main".to_string()])); + assert_eq!(config.get_deprecations(), [DeprecationWarning::BsDependencies]); + } + #[test] fn test_dev_dependencies() { let json = r#" @@ -1156,7 +1229,7 @@ pub mod tests { } #[test] - fn test_package_specs_es6_global_deprecation() { + fn test_bs_dev_dependencies_alias() { let json = r#" { "name": "testrepo", @@ -1166,21 +1239,22 @@ pub mod tests { }, "package-specs": [ { - "module": "es6-global", + "module": "esmodule", "in-source": true } ], - "suffix": ".mjs" + "suffix": ".mjs", + "bs-dev-dependencies": [ "@testrepo/main" ] } "#; - let err = Config::new_from_json_string(json).unwrap_err(); - let message = err.to_string(); - assert!(message.contains("Module system \"es6-global\" is unsupported")); + let config = Config::new_from_json_string(json).expect("a valid json string"); + assert_eq!(config.dev_dependencies, Some(vec!["@testrepo/main".to_string()])); + assert_eq!(config.get_deprecations(), [DeprecationWarning::BsDevDependencies]); } #[test] - fn test_package_specs_es6_deprecation() { + fn test_package_specs_es6_global_deprecation() { let json = r#" { "name": "testrepo", @@ -1190,7 +1264,7 @@ pub mod tests { }, "package-specs": [ { - "module": "es6", + "module": "es6-global", "in-source": true } ], @@ -1200,7 +1274,25 @@ pub mod tests { let err = Config::new_from_json_string(json).unwrap_err(); let message = err.to_string(); - assert!(message.contains("Module system \"es6\" is unsupported")); + assert!(message.contains("Module system \"es6-global\" is unsupported")); + } + + #[test] + fn test_es6_module_alias() { + let json = r#" + { + "name": "testrepo", + "sources": { "dir": "src", "subdirs": true }, + "package-specs": [ { "module": "es6", "in-source": true } ], + "suffix": ".mjs" + } + "#; + + let config = Config::new_from_json_string(json).expect("a valid json string"); + let specs = config.get_package_specs(); + assert_eq!(specs.len(), 1); + assert_eq!(specs[0].module, PackageModule::EsModule); + assert_eq!(config.get_deprecations(), [DeprecationWarning::Es6Module]); } #[test] @@ -1296,6 +1388,49 @@ pub mod tests { assert!(config.get_deprecations().is_empty()); } + #[test] + fn test_cjs_module_alias() { + let json = r#" + { + "name": "testrepo", + "sources": { "dir": "src", "subdirs": true }, + "package-specs": [ { "module": "cjs", "in-source": true } ], + "suffix": ".js" + } + "#; + + let config = Config::new_from_json_string(json).expect("a valid json string"); + let specs = config.get_package_specs(); + assert_eq!(specs.len(), 1); + assert_eq!(specs[0].module, PackageModule::CommonJs); + assert_eq!(config.get_deprecations(), [DeprecationWarning::CjsModule]); + } + + #[test] + fn test_bsc_flags_alias() { + let json = r#" + { + "name": "testrepo", + "sources": { + "dir": "src", + "subdirs": true + }, + "package-specs": [ + { + "module": "esmodule", + "in-source": true + } + ], + "suffix": ".mjs", + "bsc-flags": [ "-w" ] + } + "#; + + let config = Config::new_from_json_string(json).expect("a valid json string"); + assert!(config.compiler_flags.is_some()); + assert_eq!(config.get_deprecations(), [DeprecationWarning::BscFlags]); + } + fn test_find_is_type_dev(source: OneOrMore, path: &Path, expected: bool) { let config = Config { name: String::from("testrepo"), @@ -1501,4 +1636,22 @@ pub mod tests { "Error should include the missing config path, got: {error}" ); } + + #[test] + fn test_bsconfig_json_filename_deprecation() { + let tmp = tempfile::tempdir().expect("tempdir"); + let path = tmp.path().join("bsconfig.json"); + std::fs::write( + &path, + r#"{ "name": "legacy", "sources": { "dir": "src", "subdirs": true } }"#, + ) + .expect("write"); + + let config = Config::new(&path).expect("a valid bsconfig.json"); + assert!( + config + .get_deprecations() + .contains(&DeprecationWarning::BsconfigJson) + ); + } } diff --git a/rewatch/src/helpers.rs b/rewatch/src/helpers.rs index 600dd34ab69..876fb1beb39 100644 --- a/rewatch/src/helpers.rs +++ b/rewatch/src/helpers.rs @@ -513,7 +513,7 @@ pub fn compute_file_hash(path: &Path) -> Option { } fn has_rescript_config(path: &Path) -> bool { - path.join("rescript.json").exists() + path.join("rescript.json").exists() || path.join("bsconfig.json").exists() } // traverse up the directory tree until we find a config.json, if not return None diff --git a/rewatch/src/watcher.rs b/rewatch/src/watcher.rs index d6aba426f92..aa951cbe4ed 100644 --- a/rewatch/src/watcher.rs +++ b/rewatch/src/watcher.rs @@ -256,17 +256,17 @@ async fn async_watch( return Ok(()); } - // Detect rescript.json changes and trigger a full rebuild - if event - .paths - .iter() - .any(|p| p.file_name().map(|name| name == "rescript.json").unwrap_or(false)) - && matches!( - event.kind, - EventKind::Modify(_) | EventKind::Create(_) | EventKind::Remove(_) - ) - { - log::debug!("rescript.json changed -> full compile"); + // Detect config-file changes and trigger a full rebuild. + // Legacy bsconfig.json is accepted for backward compatibility. + if event.paths.iter().any(|p| { + p.file_name() + .map(|name| name == "rescript.json" || name == "bsconfig.json") + .unwrap_or(false) + }) && matches!( + event.kind, + EventKind::Modify(_) | EventKind::Create(_) | EventKind::Remove(_) + ) { + log::debug!("config file changed -> full compile"); needs_compile_type = CompileType::Full; continue; } diff --git a/rewatch/tests/snapshots/clean-rebuild.txt b/rewatch/tests/snapshots/clean-rebuild.txt index 5617126e645..5d6736b3b05 100644 --- a/rewatch/tests/snapshots/clean-rebuild.txt +++ b/rewatch/tests/snapshots/clean-rebuild.txt @@ -13,12 +13,21 @@ Compiled 430 modules +Package '@testrepo/deprecated-config' uses deprecated config (support will be removed in a future version): + - field 'bs-dependencies' — use 'dependencies' instead + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead + - field 'bsc-flags' — use 'compiler-flags' instead + The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system. Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. -Unknown field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. - -Unknown field 'bs-dev-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. +Package 'rescript-nodejs' uses deprecated config (support will be removed in a future version): + - field 'bs-dependencies' — use 'dependencies' instead + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead + - filename 'bsconfig.json' — rename to 'rescript.json' +Please report this to the package maintainer: https://github.com/TheSpyder/rescript-nodejs/issues -Unknown field 'bsc-flags' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. +Package 'sury' uses deprecated config (support will be removed in a future version): + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead +Please report this to the package maintainer: https://github.com/DZakh/sury/issues diff --git a/rewatch/tests/snapshots/dependency-cycle.txt b/rewatch/tests/snapshots/dependency-cycle.txt index 52fa210a123..eca324b9ed8 100644 --- a/rewatch/tests/snapshots/dependency-cycle.txt +++ b/rewatch/tests/snapshots/dependency-cycle.txt @@ -13,15 +13,24 @@ Compiled 1 modules +Package '@testrepo/deprecated-config' uses deprecated config (support will be removed in a future version): + - field 'bs-dependencies' — use 'dependencies' instead + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead + - field 'bsc-flags' — use 'compiler-flags' instead + The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system. Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. -Unknown field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. - -Unknown field 'bs-dev-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. +Package 'rescript-nodejs' uses deprecated config (support will be removed in a future version): + - field 'bs-dependencies' — use 'dependencies' instead + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead + - filename 'bsconfig.json' — rename to 'rescript.json' +Please report this to the package maintainer: https://github.com/TheSpyder/rescript-nodejs/issues -Unknown field 'bsc-flags' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. +Package 'sury' uses deprecated config (support will be removed in a future version): + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead +Please report this to the package maintainer: https://github.com/DZakh/sury/issues Can't continue... Found a circular dependency in your code: Dep01 (packages/dep01/src/Dep01.res) diff --git a/rewatch/tests/snapshots/dev-dependency-used-by-non-dev-source.txt b/rewatch/tests/snapshots/dev-dependency-used-by-non-dev-source.txt index a8b6decdf2b..3f5bf7f5404 100644 --- a/rewatch/tests/snapshots/dev-dependency-used-by-non-dev-source.txt +++ b/rewatch/tests/snapshots/dev-dependency-used-by-non-dev-source.txt @@ -13,15 +13,24 @@ Compiled 2 modules +Package '@testrepo/deprecated-config' uses deprecated config (support will be removed in a future version): + - field 'bs-dependencies' — use 'dependencies' instead + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead + - field 'bsc-flags' — use 'compiler-flags' instead + The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system. Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. -Unknown field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. - -Unknown field 'bs-dev-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. +Package 'rescript-nodejs' uses deprecated config (support will be removed in a future version): + - field 'bs-dependencies' — use 'dependencies' instead + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead + - filename 'bsconfig.json' — rename to 'rescript.json' +Please report this to the package maintainer: https://github.com/TheSpyder/rescript-nodejs/issues -Unknown field 'bsc-flags' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. +Package 'sury' uses deprecated config (support will be removed in a future version): + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead +Please report this to the package maintainer: https://github.com/DZakh/sury/issues We've found a bug for you! /packages/with-dev-deps/src/FileToTest.res:2:6-11 diff --git a/rewatch/tests/snapshots/remove-file.txt b/rewatch/tests/snapshots/remove-file.txt index 83dba834585..ff4d3970ac4 100644 --- a/rewatch/tests/snapshots/remove-file.txt +++ b/rewatch/tests/snapshots/remove-file.txt @@ -13,15 +13,24 @@ Compiled 2 modules +Package '@testrepo/deprecated-config' uses deprecated config (support will be removed in a future version): + - field 'bs-dependencies' — use 'dependencies' instead + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead + - field 'bsc-flags' — use 'compiler-flags' instead + The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system. Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. -Unknown field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. - -Unknown field 'bs-dev-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. +Package 'rescript-nodejs' uses deprecated config (support will be removed in a future version): + - field 'bs-dependencies' — use 'dependencies' instead + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead + - filename 'bsconfig.json' — rename to 'rescript.json' +Please report this to the package maintainer: https://github.com/TheSpyder/rescript-nodejs/issues -Unknown field 'bsc-flags' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. +Package 'sury' uses deprecated config (support will be removed in a future version): + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead +Please report this to the package maintainer: https://github.com/DZakh/sury/issues We've found a bug for you! /packages/dep01/src/Dep01.res:3:9-17 diff --git a/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt b/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt index 2c67137b649..6e0311b7589 100644 --- a/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt +++ b/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt @@ -13,15 +13,24 @@ Compiled 3 modules +Package '@testrepo/deprecated-config' uses deprecated config (support will be removed in a future version): + - field 'bs-dependencies' — use 'dependencies' instead + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead + - field 'bsc-flags' — use 'compiler-flags' instead + The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system. Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. -Unknown field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. - -Unknown field 'bs-dev-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. +Package 'rescript-nodejs' uses deprecated config (support will be removed in a future version): + - field 'bs-dependencies' — use 'dependencies' instead + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead + - filename 'bsconfig.json' — rename to 'rescript.json' +Please report this to the package maintainer: https://github.com/TheSpyder/rescript-nodejs/issues -Unknown field 'bsc-flags' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. +Package 'sury' uses deprecated config (support will be removed in a future version): + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead +Please report this to the package maintainer: https://github.com/DZakh/sury/issues We've found a bug for you! /packages/new-namespace/src/NS_alias.res:2:1-16 diff --git a/rewatch/tests/snapshots/rename-file-internal-dep.txt b/rewatch/tests/snapshots/rename-file-internal-dep.txt index d7982bdf5cc..68215bf2153 100644 --- a/rewatch/tests/snapshots/rename-file-internal-dep.txt +++ b/rewatch/tests/snapshots/rename-file-internal-dep.txt @@ -13,15 +13,24 @@ Compiled 3 modules +Package '@testrepo/deprecated-config' uses deprecated config (support will be removed in a future version): + - field 'bs-dependencies' — use 'dependencies' instead + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead + - field 'bsc-flags' — use 'compiler-flags' instead + The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system. Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. -Unknown field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. - -Unknown field 'bs-dev-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. +Package 'rescript-nodejs' uses deprecated config (support will be removed in a future version): + - field 'bs-dependencies' — use 'dependencies' instead + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead + - filename 'bsconfig.json' — rename to 'rescript.json' +Please report this to the package maintainer: https://github.com/TheSpyder/rescript-nodejs/issues -Unknown field 'bsc-flags' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. +Package 'sury' uses deprecated config (support will be removed in a future version): + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead +Please report this to the package maintainer: https://github.com/DZakh/sury/issues We've found a bug for you! /packages/main/src/Main.res:4:13-29 diff --git a/rewatch/tests/snapshots/rename-file-with-interface.txt b/rewatch/tests/snapshots/rename-file-with-interface.txt index 2422e04f1ac..f26462d8151 100644 --- a/rewatch/tests/snapshots/rename-file-with-interface.txt +++ b/rewatch/tests/snapshots/rename-file-with-interface.txt @@ -14,12 +14,21 @@ Compiled 2 modules +Package '@testrepo/deprecated-config' uses deprecated config (support will be removed in a future version): + - field 'bs-dependencies' — use 'dependencies' instead + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead + - field 'bsc-flags' — use 'compiler-flags' instead + The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system. Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. -Unknown field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. - -Unknown field 'bs-dev-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. +Package 'rescript-nodejs' uses deprecated config (support will be removed in a future version): + - field 'bs-dependencies' — use 'dependencies' instead + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead + - filename 'bsconfig.json' — rename to 'rescript.json' +Please report this to the package maintainer: https://github.com/TheSpyder/rescript-nodejs/issues -Unknown field 'bsc-flags' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. +Package 'sury' uses deprecated config (support will be removed in a future version): + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead +Please report this to the package maintainer: https://github.com/DZakh/sury/issues diff --git a/rewatch/tests/snapshots/rename-file.txt b/rewatch/tests/snapshots/rename-file.txt index 2ce31e691c5..347bc002df3 100644 --- a/rewatch/tests/snapshots/rename-file.txt +++ b/rewatch/tests/snapshots/rename-file.txt @@ -13,12 +13,21 @@ Compiled 2 modules +Package '@testrepo/deprecated-config' uses deprecated config (support will be removed in a future version): + - field 'bs-dependencies' — use 'dependencies' instead + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead + - field 'bsc-flags' — use 'compiler-flags' instead + The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system. Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. -Unknown field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. - -Unknown field 'bs-dev-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. +Package 'rescript-nodejs' uses deprecated config (support will be removed in a future version): + - field 'bs-dependencies' — use 'dependencies' instead + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead + - filename 'bsconfig.json' — rename to 'rescript.json' +Please report this to the package maintainer: https://github.com/TheSpyder/rescript-nodejs/issues -Unknown field 'bsc-flags' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. +Package 'sury' uses deprecated config (support will be removed in a future version): + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead +Please report this to the package maintainer: https://github.com/DZakh/sury/issues diff --git a/rewatch/tests/snapshots/rename-interface-file.txt b/rewatch/tests/snapshots/rename-interface-file.txt index 9eb5e5bdd7e..b7c694c4c33 100644 --- a/rewatch/tests/snapshots/rename-interface-file.txt +++ b/rewatch/tests/snapshots/rename-interface-file.txt @@ -14,12 +14,21 @@ Compiled 2 modules +Package '@testrepo/deprecated-config' uses deprecated config (support will be removed in a future version): + - field 'bs-dependencies' — use 'dependencies' instead + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead + - field 'bsc-flags' — use 'compiler-flags' instead + The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system. Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. -Unknown field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. - -Unknown field 'bs-dev-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. +Package 'rescript-nodejs' uses deprecated config (support will be removed in a future version): + - field 'bs-dependencies' — use 'dependencies' instead + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead + - filename 'bsconfig.json' — rename to 'rescript.json' +Please report this to the package maintainer: https://github.com/TheSpyder/rescript-nodejs/issues -Unknown field 'bsc-flags' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. +Package 'sury' uses deprecated config (support will be removed in a future version): + - field 'bs-dev-dependencies' — use 'dev-dependencies' instead +Please report this to the package maintainer: https://github.com/DZakh/sury/issues diff --git a/rewatch/tests/suite.sh b/rewatch/tests/suite.sh index b7f6bee6146..613b291d111 100755 --- a/rewatch/tests/suite.sh +++ b/rewatch/tests/suite.sh @@ -38,7 +38,7 @@ fi success "No stale rescript processes found" bold "Yarn install" -(cd ../testrepo && yarn && cp node_modules/rescript-nodejs/bsconfig.json node_modules/rescript-nodejs/rescript.json) +(cd ../testrepo && yarn) bold "Rescript version" (cd ../testrepo && ./node_modules/.bin/rescript --version) diff --git a/tests/build_tests/warn_legacy_config/input.js b/tests/build_tests/warn_legacy_config/input.js index 86d93077707..364541af502 100644 --- a/tests/build_tests/warn_legacy_config/input.js +++ b/tests/build_tests/warn_legacy_config/input.js @@ -6,6 +6,10 @@ import { setup } from "#dev/process"; const { execBuild, execClean } = setup(import.meta.dirname); const output = await execBuild(); -assert.notEqual(output.status, 0); -assert.match(output.stderr, /could not read rescript\.json/i); +assert.equal(output.status, 0); +assert.match(output.stderr, /uses deprecated config/i); +assert.match( + output.stderr, + /filename 'bsconfig\.json' .* rename to 'rescript\.json'/i, +); await execClean();