Skip to content

Adapt bsb to new rescript.json flags and remove usage of deprecated ones #7699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 23, 2025
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
4 changes: 2 additions & 2 deletions analysis/examples/example-project/rescript.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "tryit",
"sources": "src",
"bsc-flags": ["-bs-super-errors", "-open Belt"],
"compiler-flags": ["-open Belt"],
"warnings": {
"number": "-32-26-27-33"
},
"bs-dependencies": ["reason-react"],
"dependencies": ["reason-react"],
"namespace": "my-namespace",
"reanalyze": {
"analysis": ["dce", "exception"]
Expand Down
4 changes: 2 additions & 2 deletions analysis/examples/larger-project/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"unsuppress": []
},
"name": "sample-typescript-app",
"bsc-flags": ["-bs-super-errors -w a"],
"bs-dependencies": ["@rescript/react", "@glennsl/bs-json"],
"compiler-flags": ["-w a"],
"dependencies": ["@rescript/react", "@glennsl/bs-json"],
"sources": [
{
"dir": "src",
Expand Down
4 changes: 2 additions & 2 deletions analysis/examples/workspace-project/app/rescript.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "app",
"bsc-flags": ["-open Common"],
"bs-dependencies": ["common", "myplugin"],
"compiler-flags": ["-open Common"],
"dependencies": ["common", "myplugin"],
"sources": [
{
"dir": "src",
Expand Down
2 changes: 1 addition & 1 deletion analysis/examples/workspace-project/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"in-source": true
},
"suffix": ".mjs",
"bs-dependencies": ["common", "myplugin", "app"]
"dependencies": ["common", "myplugin", "app"]
}
3 changes: 3 additions & 0 deletions compiler/bsb/bsb_build_schemas.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ let name = "name"
let ppx_flags = "ppx-flags"
let pp_flags = "pp-flags"
let bs_external_includes = "bs-external-includes"
let dependencies = "dependencies"
let bs_dependencies = "bs-dependencies"
let dev_dependencies = "dev-dependencies"
let bs_dev_dependencies = "bs-dev-dependencies"
let sources = "sources"
let dir = "dir"
let files = "files"
let subdirs = "subdirs"
let compiler_flags = "compiler-flags"
let bsc_flags = "bsc-flags"
let excludes = "excludes"
let slow_re = "slow-re"
Expand Down
5 changes: 4 additions & 1 deletion compiler/bsb/bsb_build_util.ml
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,12 @@ let rec walk_all_deps_aux (visited : string Hash_string.t) (paths : string list)
)
|> ignore
in
explore_deps Bsb_build_schemas.dependencies;
explore_deps Bsb_build_schemas.bs_dependencies;
(match top with
| Expect_none -> explore_deps Bsb_build_schemas.bs_dev_dependencies
| Expect_none ->
explore_deps Bsb_build_schemas.dev_dependencies;
explore_deps Bsb_build_schemas.bs_dev_dependencies
| Expect_name _ -> ());
Queue.add {top; proj_dir = dir} queue;
Hash_string.add visited cur_package_name dir
Expand Down
26 changes: 22 additions & 4 deletions compiler/bsb/bsb_config_parse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,24 @@ let interpret_json ~(filename : string) ~(json : Ext_json_types.t)
.path)
in
let bs_dependencies =
extract_dependencies map per_proj_dir Bsb_build_schemas.bs_dependencies
let dependencies =
extract_dependencies map per_proj_dir Bsb_build_schemas.dependencies
in
if dependencies == [] then
extract_dependencies map per_proj_dir Bsb_build_schemas.bs_dependencies
else dependencies
in
let bs_dev_dependencies =
match package_kind with
| Toplevel ->
extract_dependencies map per_proj_dir
Bsb_build_schemas.bs_dev_dependencies
let dev_dependencies =
extract_dependencies map per_proj_dir
Bsb_build_schemas.dev_dependencies
in
if dev_dependencies == [] then
extract_dependencies map per_proj_dir
Bsb_build_schemas.bs_dev_dependencies
else dev_dependencies
| Dependency _ -> []
in
match map.?(Bsb_build_schemas.sources) with
Expand All @@ -258,7 +269,14 @@ let interpret_json ~(filename : string) ~(json : Ext_json_types.t)
(* ~namespace *)
sources
in
let bsc_flags = extract_string_list map Bsb_build_schemas.bsc_flags in
let bsc_flags =
let compiler_flags =
extract_string_list map Bsb_build_schemas.compiler_flags
in
if compiler_flags == [] then
extract_string_list map Bsb_build_schemas.bsc_flags
else compiler_flags
in
let jsx = Bsb_jsx.from_map map in
let jsx, bsc_flags =
match package_kind with
Expand Down
2 changes: 1 addition & 1 deletion docs/JSXV4.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ For example, suppose a V3 project uses rescript-react 0.11, which requires compa
"version": 3,
"v3-dependencies": ["rescript-react-native", "rescript-react-navigation"]
},
"bsc-flags": ["-open ReactV3"]
"compiler-flags": ["-open ReactV3"]
```

Another example is a V4 project that also uses `"rescript-react-native", "rescript-react-navigation"`. Then the setting will be:
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"in-source": false,
"suffix": ".res.js"
},
"bs-dependencies": [
"dependencies": [
"@rescript/react"
]
}
2 changes: 1 addition & 1 deletion packages/playground/scripts/generate_cmijs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ exec("yarn rescript legacy");
// Otherwise we can't use them for compilation within the playground.
buildCmij(compilerRootDir, "compiler-builtins");

const packages = resConfig["bs-dependencies"];
const packages = resConfig["dependencies"];
for (const pkgName of packages) {
buildCmij(
path.join(compilerRootDir, "node_modules", pkgName),
Expand Down
2 changes: 1 addition & 1 deletion rescript.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "rescript",
"bs-dependencies": ["@tests/gentype-react-example"]
"dependencies": ["@tests/gentype-react-example"]
}
6 changes: 3 additions & 3 deletions rewatch/CompilerConfigurationSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ This document contains a list of all bsconfig parameters with remarks, and wheth
| sources | Source | | [x] |
| sources | array of Source | | [x] |
| ignored-dirs | array of string | | [_] |
| bs-dependencies | array of string | | [x] |
| bs-dev-dependencies | array of string | | [x] |
| dependencies | array of string | | [x] |
| dev-dependencies | array of string | | [x] |
| generators | array of Rule-Generator | | [_] |
| cut-generators | boolean | | [_] |
| jsx | JSX | | [x] |
| gentypeconfig | Gentype | | [_] |
| bsc-flags | array of string | | [x] |
| compiler-flags | array of string | | [x] |
| warnings | Warnings | | [x] |
| ppx-flags | array of string | | [x] |
| pp-flags | array of string | | [_] |
Expand Down
12 changes: 6 additions & 6 deletions rewatch/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ pub mod tests {
"sources": [ { "dir": "src/", "subdirs": true } ],
"package-specs": [ { "module": "es6", "in-source": true } ],
"suffix": ".mjs",
"bs-dependencies": [ "@teamwalnut/app" ]
"dependencies": [ "@teamwalnut/app" ]
}
"#;

Expand Down Expand Up @@ -683,7 +683,7 @@ pub mod tests {
"module": "esmodule",
"in-source": true
},
"bs-dev-dependencies": ["@rescript/tools"],
"dev-dependencies": ["@rescript/tools"],
"warnings": {
"error": "+101"
}
Expand Down Expand Up @@ -714,7 +714,7 @@ pub mod tests {
"module": "esmodule",
"in-source": true
},
"bs-dev-dependencies": ["@rescript/tools"],
"dev-dependencies": ["@rescript/tools"],
"suffix": ".mjs",
"warnings": {
"error": "+101"
Expand Down Expand Up @@ -742,7 +742,7 @@ pub mod tests {
"sources": [ { "dir": "src/", "subdirs": true } ],
"package-specs": [ { "module": "es6", "in-source": true } ],
"suffix": ".mjs",
"bs-dependencies": [ "@teamwalnut/app" ],
"dependencies": [ "@teamwalnut/app" ],
"gentypeconfig": {
"module": "esmodule",
"generatedFileExtension": ".gen.tsx"
Expand All @@ -763,7 +763,7 @@ pub mod tests {
"sources": [ { "dir": "src/", "subdirs": true } ],
"package-specs": [ { "module": "es6", "in-source": true } ],
"suffix": ".mjs",
"bs-dependencies": [ "@teamwalnut/app" ],
"dependencies": [ "@teamwalnut/app" ],
"jsx": {
"module": "Voby.JSX"
}
Expand Down Expand Up @@ -792,7 +792,7 @@ pub mod tests {
"sources": [ { "dir": "src/", "subdirs": true } ],
"package-specs": [ { "module": "es6", "in-source": true } ],
"suffix": ".mjs",
"bs-dependencies": [ "@teamwalnut/app" ],
"dependencies": [ "@teamwalnut/app" ],
"jsx": { "version": 4, "preserve": true }
}
"#;
Expand Down
2 changes: 1 addition & 1 deletion rewatch/testrepo/packages/file-casing/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"suffix": ".mjs",
"dependencies": [],
"bsc-flags": [],
"compiler-flags": [],
"jsx": {
"version": 4
}
Expand Down
2 changes: 1 addition & 1 deletion rewatch/tests/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ rewatch build --snapshot-output &> ../tests/snapshots/dependency-cycle.txt
normalize_paths ../tests/snapshots/dependency-cycle.txt
git checkout -- packages/new-namespace/src/NS_alias.res

# this should not compile because "@rescript/webapi" is part of bs-dev-dependencies
# 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 --snapshot-output &> ../tests/snapshots/bs-dev-dependency-used-by-non-dev-source.txt
Expand Down
2 changes: 1 addition & 1 deletion runtime/Belt.res
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ If you want to open Belt globally for all files in your project instead, you can

```json
{
"bsc-flags": ["-open Belt"]
"compiler-flags": ["-open Belt"]
}
```

Expand Down
2 changes: 1 addition & 1 deletion runtime/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"in-source": false
}
],
"bsc-flags": [
"compiler-flags": [
"-make-runtime",
"-nostdlib",
"-nopervasives",
Expand Down
2 changes: 1 addition & 1 deletion scripts/res/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dir": "./"
}
],
"bs-dependencies": ["@tests/docstring-tests"],
"dependencies": ["@tests/docstring-tests"],
"package-specs": {
"module": "esmodule",
"in-source": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"subdirs": true
}
],
"bsc-flags": ["-w -33-44-8"],
"compiler-flags": ["-w -33-44-8"],
"jsx": { "module": "GenericJsx" }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"subdirs": true
}
],
"bsc-flags": ["-w -33-44-8"],
"compiler-flags": ["-w -33-44-8"],
"jsx": { "module": "GenericJsx" }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"name": "sample-typescript-app",
"jsx": { "version": 4 },
"bs-dependencies": ["@rescript/react"],
"dependencies": ["@rescript/react"],
"sources": [
{
"dir": "src",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"unsuppress": []
},
"name": "arnold",
"bs-dependencies": [],
"dependencies": [],
"sources": [
{
"dir": "src",
Expand Down
4 changes: 2 additions & 2 deletions tests/analysis_tests/tests/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"subdirs": true
}
],
"bsc-flags": ["-w -33-44-8"],
"bs-dependencies": ["@rescript/react"],
"compiler-flags": ["-w -33-44-8"],
"dependencies": ["@rescript/react"],
"jsx": { "version": 4 },
"suffix": ".res.js",
"editor": {
Expand Down
2 changes: 1 addition & 1 deletion tests/build_tests/case/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"name": "case",
"version": "0.1.0",
"sources": ["src"],
"bs-dependencies": []
"dependencies": []
}
2 changes: 1 addition & 1 deletion tests/build_tests/case2/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"name": "case2",
"version": "0.1.0",
"sources": ["src"],
"bs-dependencies": []
"dependencies": []
}
2 changes: 1 addition & 1 deletion tests/build_tests/case3/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"in-source": true
},
"suffix": ".res.js",
"bs-dependencies": [],
"dependencies": [],
"warnings": { "error": "+101" }
}
2 changes: 1 addition & 1 deletion tests/build_tests/custom_namespace/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"in-source": true,
"suffix": ".res.js"
},
"bsc-flags": ["-bs-no-version-header"],
"compiler-flags": ["-bs-no-version-header"],
"warnings": {
"number": "-40+6+7",
"error": true
Expand Down
2 changes: 1 addition & 1 deletion tests/build_tests/cycle/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"in-source": true,
"suffix": ".res.js"
},
"bs-dependencies": [],
"dependencies": [],
"warnings": { "error": "+101" }
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"in-source": true,
"suffix": ".res.js"
},
"bs-dependencies": ["c", "z"],
"dependencies": ["c", "z"],
"warnings": { "error": "+101" },
"namespace": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"in-source": true,
"suffix": ".res.js"
},
"bs-dependencies": ["c"],
"dependencies": ["c"],
"warnings": { "error": "+101" },
"namespace": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"name": "duplicated-symlinked-packages",
"version": "0.1.0",
"sources": ["src"],
"bs-dependencies": ["a", "b", "z"]
"dependencies": ["a", "b", "z"]
}
2 changes: 1 addition & 1 deletion tests/build_tests/install/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"in-source": true,
"suffix": ".res.js"
},
"bs-dependencies": [],
"dependencies": [],
"warnings": { "error": "+101" }
}
2 changes: 1 addition & 1 deletion tests/build_tests/jsx_settings_inheritance/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"suffix": ".res.js"
},
"namespace": true,
"bs-dependencies": ["@rescript/react", "a", "b"]
"dependencies": ["@rescript/react", "a", "b"]
}
2 changes: 1 addition & 1 deletion tests/build_tests/rerror/rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"name": "rerror",
"version": "0.1.0",
"sources": ["src"],
"bs-dependencies": []
"dependencies": []
}
Loading