Skip to content
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 @@ -20,6 +20,7 @@
- Remove `external-stdlib` configuration option from `rescript.json`. This option was rarely used and is no longer supported.
- `js-post-build` now passes the correct output file path based on `in-source` configuration: when `in-source: true`, the path next to the source file is passed; when `in-source: false`, the path in the `lib/<module>/` directory is passed. Additionally, stdout and stderr from the post-build command are now logged. https://github.com/rescript-lang/rescript/pull/8190
- `js-post-build` command now runs in the directory containing the `rescript.json` where it is defined, instead of the unpredictable build invocation directory. This provides consistent behavior in monorepos. https://github.com/rescript-lang/rescript/pull/8195
- Remove support for deprecated `bs-dependencies`, `bs-dev-dependencies`, and `bsc-flags` configuration options. Use `dependencies`, `dev-dependencies`, and `compiler-flags` instead. https://github.com/rescript-lang/rescript/pull/8196

#### :eyeglasses: Spec Compliance

Expand Down
6 changes: 2 additions & 4 deletions compiler/gentype/GenTypeConfig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,8 @@ let read_config ~get_config_file ~namespace =
| _ -> default.suffix
in
let bs_dependencies =
match
(bsconf |> get_opt "dependencies", bsconf |> get_opt "bs-dependencies")
with
| Some (Arr {content}), None | None, Some (Arr {content}) ->
match bsconf |> get_opt "dependencies" with
| Some (Arr {content}) ->
let strings = ref [] in
content
|> Array.iter (fun x ->
Expand Down
12 changes: 0 additions & 12 deletions docs/docson/build-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,6 @@
},
"description": "a list of directories that the build system will not look into"
},
"bs-dependencies": {
"$ref": "#/definitions/dependencies",
"description": "ReScript dependencies of the library, like in package.json. Currently searches in `node_modules` (deprecated, use dependencies instead)."
},
"bs-dev-dependencies": {
"$ref": "#/definitions/dependencies",
"description": "ReScript dev dependencies of the library, like in package.json. Currently searches in `node_modules` (deprecated, use dev-dependencies instead)."
},
"dependencies": {
"$ref": "#/definitions/dependencies",
"description": "ReScript dependencies of the library, like in package.json. Currently searches in `node_modules`."
Expand Down Expand Up @@ -414,10 +406,6 @@
"$ref": "#/definitions/gentype-specs",
"description": "gentype config, see cristianoc/genType for more details"
},
"bsc-flags": {
"$ref": "#/definitions/compiler-flags",
"description": "Flags passed to bsc.exe (deprecated, use compiler-flags instead)"
},
"compiler-flags": {
"$ref": "#/definitions/compiler-flags",
"description": "Flags passed to bsc.exe"
Expand Down
17 changes: 0 additions & 17 deletions rewatch/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,15 +419,6 @@ fn log_config_warnings(build_state: &BuildCommandState) {
if package.is_local_dep {
package.config.get_deprecations().iter().for_each(
|deprecation_warning| match deprecation_warning {
config::DeprecationWarning::BsDependencies => {
log_deprecated_config_field(&package.name, "bs-dependencies", "dependencies");
}
config::DeprecationWarning::BsDevDependencies => {
log_deprecated_config_field(&package.name, "bs-dev-dependencies", "dev-dependencies");
}
config::DeprecationWarning::BscFlags => {
log_deprecated_config_field(&package.name, "bsc-flags", "compiler-flags");
}
config::DeprecationWarning::PackageSpecsEs6 => {
log_deprecated_package_specs_module("es6");
}
Expand All @@ -452,14 +443,6 @@ fn log_config_warnings(build_state: &BuildCommandState) {
});
}

fn log_deprecated_config_field(package_name: &str, field_name: &str, new_field_name: &str) {
let warning = format!(
"The field '{field_name}' found in the package config of '{package_name}' is deprecated and will be removed in a future version.\n\
Use '{new_field_name}' instead."
);
eprintln!("\n{}", style(warning).yellow());
}

fn log_deprecated_package_specs_module(module_name: &str) {
let warning = format!("deprecated: Option \"{module_name}\" is deprecated. Use \"esmodule\" instead.");
eprintln!("\n{}", style(warning).yellow());
Expand Down
22 changes: 11 additions & 11 deletions rewatch/src/build/packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,36 +948,36 @@ fn get_unallowed_dependents(
}
#[derive(Debug, Clone)]
struct UnallowedDependency {
bs_deps: Vec<String>,
bs_build_dev_deps: Vec<String>,
deps: Vec<String>,
dev_deps: Vec<String>,
}

pub fn validate_packages_dependencies(packages: &AHashMap<String, Package>) -> bool {
let mut detected_unallowed_dependencies: AHashMap<String, UnallowedDependency> = AHashMap::new();

for (package_name, package) in packages {
let bs_dependencies = &package.config.dependencies.to_owned().unwrap_or(vec![]);
let dependencies = &package.config.dependencies.to_owned().unwrap_or(vec![]);
let dev_dependencies = &package.config.dev_dependencies.to_owned().unwrap_or(vec![]);

[
("bs-dependencies", bs_dependencies),
("bs-dev-dependencies", dev_dependencies),
("dependencies", dependencies),
("dev-dependencies", dev_dependencies),
]
.iter()
.for_each(|(dependency_type, dependencies)| {
if let Some(unallowed_dependency_name) =
get_unallowed_dependents(packages, package_name, dependencies)
{
let empty_unallowed_deps = UnallowedDependency {
bs_deps: vec![],
bs_build_dev_deps: vec![],
deps: vec![],
dev_deps: vec![],
};

let unallowed_dependency = detected_unallowed_dependencies.entry(String::from(package_name));
let value = unallowed_dependency.or_insert_with(|| empty_unallowed_deps);
match *dependency_type {
"bs-dependencies" => value.bs_deps.push(unallowed_dependency_name),
"bs-dev-dependencies" => value.bs_build_dev_deps.push(unallowed_dependency_name),
"dependencies" => value.deps.push(unallowed_dependency_name),
"dev-dependencies" => value.dev_deps.push(unallowed_dependency_name),
_ => (),
}
}
Expand All @@ -991,8 +991,8 @@ pub fn validate_packages_dependencies(packages: &AHashMap<String, Package>) -> b
);

[
("bs-dependencies", unallowed_deps.bs_deps.to_owned()),
("bs-dev-dependencies", unallowed_deps.bs_build_dev_deps.to_owned()),
("dependencies", unallowed_deps.deps.to_owned()),
("dev-dependencies", unallowed_deps.dev_deps.to_owned()),
]
.iter()
.for_each(|(deps_type, map)| {
Expand Down
118 changes: 1 addition & 117 deletions rewatch/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::build::packages;
use crate::helpers;
use crate::helpers::deserialize::*;
use crate::project_context::ProjectContext;
use anyhow::{Result, anyhow, bail};
use anyhow::{Result, anyhow};
use convert_case::{Case, Casing};
use serde::de::{Error as DeError, Visitor};
use serde::{Deserialize, Deserializer};
Expand Down Expand Up @@ -228,9 +228,6 @@ pub struct JsPostBuild {

#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub enum DeprecationWarning {
BsDependencies,
BsDevDependencies,
BscFlags,
PackageSpecsEs6,
PackageSpecsEs6Global,
}
Expand Down Expand Up @@ -285,20 +282,11 @@ pub struct Config {
pub dependencies: Option<Vec<String>>,
#[serde(rename = "dev-dependencies")]
pub dev_dependencies: Option<Vec<String>>,
// Deprecated field: overwrites dependencies
#[serde(rename = "bs-dependencies")]
bs_dependencies: Option<Vec<String>>,
// Deprecated field: overwrites dev_dependencies
#[serde(rename = "bs-dev-dependencies")]
bs_dev_dependencies: Option<Vec<String>>,
#[serde(rename = "ppx-flags")]
pub ppx_flags: Option<Vec<OneOrMore<String>>>,

#[serde(rename = "compiler-flags")]
pub compiler_flags: Option<Vec<OneOrMore<String>>>,
// Deprecated field: overwrites compiler_flags
#[serde(rename = "bsc-flags")]
bsc_flags: Option<Vec<OneOrMore<String>>>,

pub namespace: Option<NamespaceConfig>,
pub jsx: Option<JsxSpecs>,
Expand Down Expand Up @@ -729,33 +717,6 @@ impl Config {
}

fn handle_deprecations(&mut self) -> Result<()> {
if self.dependencies.is_some() && self.bs_dependencies.is_some() {
bail!("dependencies and bs-dependencies are mutually exclusive. Please use 'dependencies'.");
}
if self.dev_dependencies.is_some() && self.bs_dev_dependencies.is_some() {
bail!(
"dev-dependencies and bs-dev-dependencies are mutually exclusive. Please use 'dev-dependencies'"
);
}

if self.compiler_flags.is_some() && self.bsc_flags.is_some() {
bail!("compiler-flags and bsc-flags are mutually exclusive. Please use 'compiler-flags'");
}

if self.bs_dependencies.is_some() {
self.dependencies = self.bs_dependencies.take();
self.deprecation_warnings.push(DeprecationWarning::BsDependencies);
}
if self.bs_dev_dependencies.is_some() {
self.dev_dependencies = self.bs_dev_dependencies.take();
self.deprecation_warnings
.push(DeprecationWarning::BsDevDependencies);
}
if self.bsc_flags.is_some() {
self.compiler_flags = self.bsc_flags.take();
self.deprecation_warnings.push(DeprecationWarning::BscFlags);
}

let (has_es6, has_es6_global) = match &self.package_specs {
None => (false, false),
Some(OneOrMore::Single(spec)) => (spec.module == "es6", spec.module == "es6-global"),
Expand Down Expand Up @@ -800,11 +761,8 @@ pub mod tests {
suffix: None,
dependencies: Some(args.bs_deps),
dev_dependencies: Some(args.build_dev_deps),
bs_dependencies: None,
bs_dev_dependencies: None,
ppx_flags: None,
compiler_flags: None,
bsc_flags: None,
namespace: None,
jsx: None,
gentype_config: None,
Expand Down Expand Up @@ -1010,31 +968,6 @@ pub mod tests {
);
}

#[test]
fn test_dependencies_deprecation() {
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_dependencies() {
let json = r#"
Expand All @@ -1060,31 +993,6 @@ pub mod tests {
assert!(config.get_deprecations().is_empty());
}

#[test]
fn test_dev_dependencies_deprecation() {
let json = r#"
{
"name": "testrepo",
"sources": {
"dir": "src",
"subdirs": true
},
"package-specs": [
{
"module": "esmodule",
"in-source": true
}
],
"suffix": ".mjs",
"bs-dev-dependencies": [ "@testrepo/main" ]
}
"#;

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_dev_dependencies() {
let json = r#"
Expand Down Expand Up @@ -1252,30 +1160,6 @@ pub mod tests {
assert!(config.get_deprecations().is_empty());
}

#[test]
fn test_compiler_flags_deprecation() {
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_eq!(config.get_deprecations(), [DeprecationWarning::BscFlags]);
}

fn test_find_is_type_dev(source: OneOrMore<Source>, path: &Path, expected: bool) {
let config = Config {
name: String::from("testrepo"),
Expand Down
4 changes: 2 additions & 2 deletions rewatch/tests/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ rm -rf packages/main/src/dupe-a packages/main/src/dupe-b
# this should not compile because "@rescript/webapi" is part of dev-dependencies
# and FileToTest.res is not listed as "type":"dev"
echo 'open WebAPI' >> packages/with-dev-deps/src/FileToTest.res
rewatch build &> ../tests/snapshots/bs-dev-dependency-used-by-non-dev-source.txt
normalize_paths ../tests/snapshots/bs-dev-dependency-used-by-non-dev-source.txt
rewatch build &> ../tests/snapshots/dev-dependency-used-by-non-dev-source.txt
normalize_paths ../tests/snapshots/dev-dependency-used-by-non-dev-source.txt
git checkout -- packages/with-dev-deps/src/FileToTest.res

# it should compile dev dependencies
Expand Down
13 changes: 5 additions & 8 deletions rewatch/tests/snapshots/clean-rebuild.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ Cleaned 0/0
Parsed 425 source files
Compiled 425 modules

The field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config' is deprecated and will be removed in a future version.
Use 'dependencies' instead.
The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system.

The field 'bs-dev-dependencies' found in the package config of '@testrepo/deprecated-config' is deprecated and will be removed in a future version.
Use 'dev-dependencies' instead.
Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored.

The field 'bsc-flags' found in the package config of '@testrepo/deprecated-config' is deprecated and will be removed in a future version.
Use 'compiler-flags' instead.
Unknown field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored.

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 'bs-dev-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored.

Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored.
Unknown field 'bsc-flags' found in the package config of '@testrepo/deprecated-config'. This option will be ignored.
13 changes: 5 additions & 8 deletions rewatch/tests/snapshots/dependency-cycle.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@ Cleaned 0/428
Parsed 1 source files
Compiled 0 modules

The field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config' is deprecated and will be removed in a future version.
Use 'dependencies' instead.
The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system.

The field 'bs-dev-dependencies' found in the package config of '@testrepo/deprecated-config' is deprecated and will be removed in a future version.
Use 'dev-dependencies' instead.
Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored.

The field 'bsc-flags' found in the package config of '@testrepo/deprecated-config' is deprecated and will be removed in a future version.
Use 'compiler-flags' instead.
Unknown field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored.

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 'bs-dev-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored.

Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored.
Unknown field 'bsc-flags' found in the package config of '@testrepo/deprecated-config'. This option will be ignored.

Can't continue... Found a circular dependency in your code:
Dep01 (packages/dep01/src/Dep01.res)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@ Cleaned 0/428
Parsed 2 source files
Compiled 2 modules

The field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config' is deprecated and will be removed in a future version.
Use 'dependencies' instead.
The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system.

The field 'bs-dev-dependencies' found in the package config of '@testrepo/deprecated-config' is deprecated and will be removed in a future version.
Use 'dev-dependencies' instead.
Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored.

The field 'bsc-flags' found in the package config of '@testrepo/deprecated-config' is deprecated and will be removed in a future version.
Use 'compiler-flags' instead.
Unknown field 'bs-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored.

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 'bs-dev-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored.

Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored.
Unknown field 'bsc-flags' found in the package config of '@testrepo/deprecated-config'. This option will be ignored.

We've found a bug for you!
/packages/with-dev-deps/src/FileToTest.res:2:6-11
Expand Down
Loading
Loading