Skip to content

Commit df33e5d

Browse files
authored
Remove old configuration flags (#8196)
* Remove old configuratio flags * Add changelog entry
1 parent 893ab5d commit df33e5d

File tree

20 files changed

+67
-240
lines changed

20 files changed

+67
-240
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- Remove `external-stdlib` configuration option from `rescript.json`. This option was rarely used and is no longer supported.
2121
- `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
2222
- `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
23+
- 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
2324

2425
#### :eyeglasses: Spec Compliance
2526

compiler/gentype/GenTypeConfig.ml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,8 @@ let read_config ~get_config_file ~namespace =
194194
| _ -> default.suffix
195195
in
196196
let bs_dependencies =
197-
match
198-
(bsconf |> get_opt "dependencies", bsconf |> get_opt "bs-dependencies")
199-
with
200-
| Some (Arr {content}), None | None, Some (Arr {content}) ->
197+
match bsconf |> get_opt "dependencies" with
198+
| Some (Arr {content}) ->
201199
let strings = ref [] in
202200
content
203201
|> Array.iter (fun x ->

docs/docson/build-schema.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -375,14 +375,6 @@
375375
},
376376
"description": "a list of directories that the build system will not look into"
377377
},
378-
"bs-dependencies": {
379-
"$ref": "#/definitions/dependencies",
380-
"description": "ReScript dependencies of the library, like in package.json. Currently searches in `node_modules` (deprecated, use dependencies instead)."
381-
},
382-
"bs-dev-dependencies": {
383-
"$ref": "#/definitions/dependencies",
384-
"description": "ReScript dev dependencies of the library, like in package.json. Currently searches in `node_modules` (deprecated, use dev-dependencies instead)."
385-
},
386378
"dependencies": {
387379
"$ref": "#/definitions/dependencies",
388380
"description": "ReScript dependencies of the library, like in package.json. Currently searches in `node_modules`."
@@ -414,10 +406,6 @@
414406
"$ref": "#/definitions/gentype-specs",
415407
"description": "gentype config, see cristianoc/genType for more details"
416408
},
417-
"bsc-flags": {
418-
"$ref": "#/definitions/compiler-flags",
419-
"description": "Flags passed to bsc.exe (deprecated, use compiler-flags instead)"
420-
},
421409
"compiler-flags": {
422410
"$ref": "#/definitions/compiler-flags",
423411
"description": "Flags passed to bsc.exe"

rewatch/src/build.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -419,15 +419,6 @@ fn log_config_warnings(build_state: &BuildCommandState) {
419419
if package.is_local_dep {
420420
package.config.get_deprecations().iter().for_each(
421421
|deprecation_warning| match deprecation_warning {
422-
config::DeprecationWarning::BsDependencies => {
423-
log_deprecated_config_field(&package.name, "bs-dependencies", "dependencies");
424-
}
425-
config::DeprecationWarning::BsDevDependencies => {
426-
log_deprecated_config_field(&package.name, "bs-dev-dependencies", "dev-dependencies");
427-
}
428-
config::DeprecationWarning::BscFlags => {
429-
log_deprecated_config_field(&package.name, "bsc-flags", "compiler-flags");
430-
}
431422
config::DeprecationWarning::PackageSpecsEs6 => {
432423
log_deprecated_package_specs_module("es6");
433424
}
@@ -452,14 +443,6 @@ fn log_config_warnings(build_state: &BuildCommandState) {
452443
});
453444
}
454445

455-
fn log_deprecated_config_field(package_name: &str, field_name: &str, new_field_name: &str) {
456-
let warning = format!(
457-
"The field '{field_name}' found in the package config of '{package_name}' is deprecated and will be removed in a future version.\n\
458-
Use '{new_field_name}' instead."
459-
);
460-
eprintln!("\n{}", style(warning).yellow());
461-
}
462-
463446
fn log_deprecated_package_specs_module(module_name: &str) {
464447
let warning = format!("deprecated: Option \"{module_name}\" is deprecated. Use \"esmodule\" instead.");
465448
eprintln!("\n{}", style(warning).yellow());

rewatch/src/build/packages.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -948,36 +948,36 @@ fn get_unallowed_dependents(
948948
}
949949
#[derive(Debug, Clone)]
950950
struct UnallowedDependency {
951-
bs_deps: Vec<String>,
952-
bs_build_dev_deps: Vec<String>,
951+
deps: Vec<String>,
952+
dev_deps: Vec<String>,
953953
}
954954

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

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

962962
[
963-
("bs-dependencies", bs_dependencies),
964-
("bs-dev-dependencies", dev_dependencies),
963+
("dependencies", dependencies),
964+
("dev-dependencies", dev_dependencies),
965965
]
966966
.iter()
967967
.for_each(|(dependency_type, dependencies)| {
968968
if let Some(unallowed_dependency_name) =
969969
get_unallowed_dependents(packages, package_name, dependencies)
970970
{
971971
let empty_unallowed_deps = UnallowedDependency {
972-
bs_deps: vec![],
973-
bs_build_dev_deps: vec![],
972+
deps: vec![],
973+
dev_deps: vec![],
974974
};
975975

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

993993
[
994-
("bs-dependencies", unallowed_deps.bs_deps.to_owned()),
995-
("bs-dev-dependencies", unallowed_deps.bs_build_dev_deps.to_owned()),
994+
("dependencies", unallowed_deps.deps.to_owned()),
995+
("dev-dependencies", unallowed_deps.dev_deps.to_owned()),
996996
]
997997
.iter()
998998
.for_each(|(deps_type, map)| {

rewatch/src/config.rs

Lines changed: 1 addition & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::build::packages;
22
use crate::helpers;
33
use crate::helpers::deserialize::*;
44
use crate::project_context::ProjectContext;
5-
use anyhow::{Result, anyhow, bail};
5+
use anyhow::{Result, anyhow};
66
use convert_case::{Case, Casing};
77
use serde::de::{Error as DeError, Visitor};
88
use serde::{Deserialize, Deserializer};
@@ -228,9 +228,6 @@ pub struct JsPostBuild {
228228

229229
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
230230
pub enum DeprecationWarning {
231-
BsDependencies,
232-
BsDevDependencies,
233-
BscFlags,
234231
PackageSpecsEs6,
235232
PackageSpecsEs6Global,
236233
}
@@ -285,20 +282,11 @@ pub struct Config {
285282
pub dependencies: Option<Vec<String>>,
286283
#[serde(rename = "dev-dependencies")]
287284
pub dev_dependencies: Option<Vec<String>>,
288-
// Deprecated field: overwrites dependencies
289-
#[serde(rename = "bs-dependencies")]
290-
bs_dependencies: Option<Vec<String>>,
291-
// Deprecated field: overwrites dev_dependencies
292-
#[serde(rename = "bs-dev-dependencies")]
293-
bs_dev_dependencies: Option<Vec<String>>,
294285
#[serde(rename = "ppx-flags")]
295286
pub ppx_flags: Option<Vec<OneOrMore<String>>>,
296287

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

303291
pub namespace: Option<NamespaceConfig>,
304292
pub jsx: Option<JsxSpecs>,
@@ -729,33 +717,6 @@ impl Config {
729717
}
730718

731719
fn handle_deprecations(&mut self) -> Result<()> {
732-
if self.dependencies.is_some() && self.bs_dependencies.is_some() {
733-
bail!("dependencies and bs-dependencies are mutually exclusive. Please use 'dependencies'.");
734-
}
735-
if self.dev_dependencies.is_some() && self.bs_dev_dependencies.is_some() {
736-
bail!(
737-
"dev-dependencies and bs-dev-dependencies are mutually exclusive. Please use 'dev-dependencies'"
738-
);
739-
}
740-
741-
if self.compiler_flags.is_some() && self.bsc_flags.is_some() {
742-
bail!("compiler-flags and bsc-flags are mutually exclusive. Please use 'compiler-flags'");
743-
}
744-
745-
if self.bs_dependencies.is_some() {
746-
self.dependencies = self.bs_dependencies.take();
747-
self.deprecation_warnings.push(DeprecationWarning::BsDependencies);
748-
}
749-
if self.bs_dev_dependencies.is_some() {
750-
self.dev_dependencies = self.bs_dev_dependencies.take();
751-
self.deprecation_warnings
752-
.push(DeprecationWarning::BsDevDependencies);
753-
}
754-
if self.bsc_flags.is_some() {
755-
self.compiler_flags = self.bsc_flags.take();
756-
self.deprecation_warnings.push(DeprecationWarning::BscFlags);
757-
}
758-
759720
let (has_es6, has_es6_global) = match &self.package_specs {
760721
None => (false, false),
761722
Some(OneOrMore::Single(spec)) => (spec.module == "es6", spec.module == "es6-global"),
@@ -800,11 +761,8 @@ pub mod tests {
800761
suffix: None,
801762
dependencies: Some(args.bs_deps),
802763
dev_dependencies: Some(args.build_dev_deps),
803-
bs_dependencies: None,
804-
bs_dev_dependencies: None,
805764
ppx_flags: None,
806765
compiler_flags: None,
807-
bsc_flags: None,
808766
namespace: None,
809767
jsx: None,
810768
gentype_config: None,
@@ -1010,31 +968,6 @@ pub mod tests {
1010968
);
1011969
}
1012970

1013-
#[test]
1014-
fn test_dependencies_deprecation() {
1015-
let json = r#"
1016-
{
1017-
"name": "testrepo",
1018-
"sources": {
1019-
"dir": "src",
1020-
"subdirs": true
1021-
},
1022-
"package-specs": [
1023-
{
1024-
"module": "esmodule",
1025-
"in-source": true
1026-
}
1027-
],
1028-
"suffix": ".mjs",
1029-
"bs-dependencies": [ "@testrepo/main" ]
1030-
}
1031-
"#;
1032-
1033-
let config = Config::new_from_json_string(json).expect("a valid json string");
1034-
assert_eq!(config.dependencies, Some(vec!["@testrepo/main".to_string()]));
1035-
assert_eq!(config.get_deprecations(), [DeprecationWarning::BsDependencies]);
1036-
}
1037-
1038971
#[test]
1039972
fn test_dependencies() {
1040973
let json = r#"
@@ -1060,31 +993,6 @@ pub mod tests {
1060993
assert!(config.get_deprecations().is_empty());
1061994
}
1062995

1063-
#[test]
1064-
fn test_dev_dependencies_deprecation() {
1065-
let json = r#"
1066-
{
1067-
"name": "testrepo",
1068-
"sources": {
1069-
"dir": "src",
1070-
"subdirs": true
1071-
},
1072-
"package-specs": [
1073-
{
1074-
"module": "esmodule",
1075-
"in-source": true
1076-
}
1077-
],
1078-
"suffix": ".mjs",
1079-
"bs-dev-dependencies": [ "@testrepo/main" ]
1080-
}
1081-
"#;
1082-
1083-
let config = Config::new_from_json_string(json).expect("a valid json string");
1084-
assert_eq!(config.dev_dependencies, Some(vec!["@testrepo/main".to_string()]));
1085-
assert_eq!(config.get_deprecations(), [DeprecationWarning::BsDevDependencies]);
1086-
}
1087-
1088996
#[test]
1089997
fn test_dev_dependencies() {
1090998
let json = r#"
@@ -1252,30 +1160,6 @@ pub mod tests {
12521160
assert!(config.get_deprecations().is_empty());
12531161
}
12541162

1255-
#[test]
1256-
fn test_compiler_flags_deprecation() {
1257-
let json = r#"
1258-
{
1259-
"name": "testrepo",
1260-
"sources": {
1261-
"dir": "src",
1262-
"subdirs": true
1263-
},
1264-
"package-specs": [
1265-
{
1266-
"module": "esmodule",
1267-
"in-source": true
1268-
}
1269-
],
1270-
"suffix": ".mjs",
1271-
"bsc-flags": [ "-w" ]
1272-
}
1273-
"#;
1274-
1275-
let config = Config::new_from_json_string(json).expect("a valid json string");
1276-
assert_eq!(config.get_deprecations(), [DeprecationWarning::BscFlags]);
1277-
}
1278-
12791163
fn test_find_is_type_dev(source: OneOrMore<Source>, path: &Path, expected: bool) {
12801164
let config = Config {
12811165
name: String::from("testrepo"),

rewatch/tests/compile.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ rm -rf packages/main/src/dupe-a packages/main/src/dupe-b
104104
# this should not compile because "@rescript/webapi" is part of dev-dependencies
105105
# and FileToTest.res is not listed as "type":"dev"
106106
echo 'open WebAPI' >> packages/with-dev-deps/src/FileToTest.res
107-
rewatch build &> ../tests/snapshots/bs-dev-dependency-used-by-non-dev-source.txt
108-
normalize_paths ../tests/snapshots/bs-dev-dependency-used-by-non-dev-source.txt
107+
rewatch build &> ../tests/snapshots/dev-dependency-used-by-non-dev-source.txt
108+
normalize_paths ../tests/snapshots/dev-dependency-used-by-non-dev-source.txt
109109
git checkout -- packages/with-dev-deps/src/FileToTest.res
110110

111111
# it should compile dev dependencies

rewatch/tests/snapshots/clean-rebuild.txt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@ Cleaned 0/0
22
Parsed 425 source files
33
Compiled 425 modules
44

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

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

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

14-
The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system.
11+
Unknown field 'bs-dev-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored.
1512

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

rewatch/tests/snapshots/dependency-cycle.txt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@ Cleaned 0/428
22
Parsed 1 source files
33
Compiled 0 modules
44

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

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

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

14-
The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system.
11+
Unknown field 'bs-dev-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored.
1512

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

1815
Can't continue... Found a circular dependency in your code:
1916
Dep01 (packages/dep01/src/Dep01.res)

rewatch/tests/snapshots/bs-dev-dependency-used-by-non-dev-source.txt renamed to rewatch/tests/snapshots/dev-dependency-used-by-non-dev-source.txt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@ Cleaned 0/428
22
Parsed 2 source files
33
Compiled 2 modules
44

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

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

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

14-
The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system.
11+
Unknown field 'bs-dev-dependencies' found in the package config of '@testrepo/deprecated-config'. This option will be ignored.
1512

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

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

0 commit comments

Comments
 (0)