Skip to content

Commit cba7ed7

Browse files
authored
Remove support for bsconfig.json (#8187)
* Remove support for bsconfig.json * Adapt test * comments * rename * doc * Fix rewatch tests * rename * CHANGELOG
1 parent 4092d3d commit cba7ed7

22 files changed

Lines changed: 34 additions & 75 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ jobs:
9393
- name: Install npm packages
9494
run: yarn install
9595

96-
- name: Install testrepo deps
97-
run: cd rewatch/testrepo && yarn install
98-
9996
- name: Install dependencies (Linux)
10097
if: runner.os == 'Linux'
10198
uses: awalsh128/cache-apt-pkgs-action@v1.4.3

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#### :boom: Breaking Change
1616

1717
- Remove the legacy build system. Going forward, only the modern build system is supported, and the `rescript-legacy` command is not available anymore. https://github.com/rescript-lang/rescript/pull/8186
18+
- Remove support for `bsconfig.json`. https://github.com/rescript-lang/rescript/pull/8187
1819
- `Int.fromString` and `Float.fromString` use stricter number parsing and no longer uses an explicit radix argument, but instead supports parsing hexadecimal, binary and exponential notation.
1920
- Remove `external-stdlib` configuration option from `rescript.json`. This option was rarely used and is no longer supported.
2021
- `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

analysis/reanalyze/src/Paths.ml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module StringMap = Map_string
22

3-
let bsconfig = "bsconfig.json"
43
let rescriptJson = "rescript.json"
54

65
let readFile filename =
@@ -14,8 +13,7 @@ let readFile filename =
1413

1514
let rec findProjectRoot ~dir =
1615
let rescriptJsonFile = Filename.concat dir rescriptJson in
17-
let bsconfigFile = Filename.concat dir bsconfig in
18-
if Sys.file_exists rescriptJsonFile || Sys.file_exists bsconfigFile then dir
16+
if Sys.file_exists rescriptJsonFile then dir
1917
else
2018
let parent = dir |> Filename.dirname in
2119
if parent = dir then (
@@ -84,10 +82,9 @@ module Config = struct
8482
| _ -> ()
8583

8684
(* Read the config from rescript.json and apply it to runConfig and suppress and unsuppress *)
87-
let processBsconfig () =
85+
let processConfig () =
8886
setProjectRootFromCwd ();
8987
let rescriptFile = Filename.concat runConfig.projectRoot rescriptJson in
90-
let bsconfigFile = Filename.concat runConfig.projectRoot bsconfig in
9188

9289
let processText text =
9390
match Json.parse text with
@@ -106,10 +103,7 @@ module Config = struct
106103

107104
match readFile rescriptFile with
108105
| Some text -> processText text
109-
| None -> (
110-
match readFile bsconfigFile with
111-
| Some text -> processText text
112-
| None -> ())
106+
| None -> ()
113107
end
114108

115109
(**

analysis/reanalyze/src/Reanalyze.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ let parse_argv (argv : string array) : string option =
657657
cmtRootRef := cmtRoot;
658658
analysisKindSet := true
659659
and setConfig () =
660-
Paths.Config.processBsconfig ();
660+
Paths.Config.processConfig ();
661661
analysisKindSet := true
662662
and setDCE cmtRoot =
663663
RunConfig.dce ();
@@ -787,7 +787,7 @@ let parse_argv (argv : string array) : string option =
787787
- reanalyze can be called from anywhere within the project
788788
789789
Project root detection reuses the same logic as reanalyze config discovery:
790-
walk up from a directory until we find rescript.json or bsconfig.json. *)
790+
walk up from a directory until we find rescript.json. *)
791791
let cli () =
792792
let cmtRoot = parse_argv Sys.argv in
793793
runAnalysisAndReport ~cmtRoot

analysis/reanalyze/src/ReanalyzeServer.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
- reanalyze can be called from anywhere within the project
77
88
Project root detection reuses the same logic as reanalyze config discovery:
9-
walk up from a directory until we find rescript.json or bsconfig.json. *)
9+
walk up from a directory until we find rescript.json. *)
1010
let default_socket_filename = ".rescript-reanalyze.sock"
1111

1212
let project_root_from_dir (dir : string) : string option =

analysis/src/FindFiles.ml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ let findDependencyFiles base config =
241241
(ModuleResolution.resolveNodeModulePath ~startPath:base name)
242242
(fun path ->
243243
let rescriptJsonPath = path /+ "rescript.json" in
244-
let bsconfigJsonPath = path /+ "bsconfig.json" in
245244

246245
let parseText text =
247246
match Json.parse text with
@@ -272,10 +271,7 @@ let findDependencyFiles base config =
272271

273272
match Files.readFile rescriptJsonPath with
274273
| Some text -> parseText text
275-
| None -> (
276-
match Files.readFile bsconfigJsonPath with
277-
| Some text -> parseText text
278-
| None -> None))
274+
| None -> None)
279275
in
280276

281277
match result with

analysis/src/Packages.ml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ let getReScriptVersion () =
3434

3535
let newBsPackage ~rootPath =
3636
let rescriptJson = Filename.concat rootPath "rescript.json" in
37-
let bsconfigJson = Filename.concat rootPath "bsconfig.json" in
3837

3938
let parseRaw raw =
4039
let libBs =
@@ -192,23 +191,17 @@ let newBsPackage ~rootPath =
192191

193192
match Files.readFile rescriptJson with
194193
| Some raw -> parseRaw raw
195-
| None -> (
194+
| None ->
196195
Log.log ("Unable to read " ^ rescriptJson);
197-
match Files.readFile bsconfigJson with
198-
| Some raw -> parseRaw raw
199-
| None ->
200-
Log.log ("Unable to read " ^ bsconfigJson);
201-
None)
196+
None
202197

203198
let findRoot ~uri packagesByRoot =
204199
let path = Uri.toPath uri in
205200
let rec loop path =
206201
if path = "/" then None
207202
else if Hashtbl.mem packagesByRoot path then Some (`Root path)
208-
else if
209-
Files.exists (Filename.concat path "rescript.json")
210-
|| Files.exists (Filename.concat path "bsconfig.json")
211-
then Some (`Bs path)
203+
else if Files.exists (Filename.concat path "rescript.json") then
204+
Some (`Bs path)
212205
else
213206
let parent = Filename.dirname path in
214207
if parent = path then (* reached root *) None else loop parent

compiler/ext/ext_path.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ let rec find_root_filename ~cwd filenames =
268268
Ext_fmt.failwithf ~loc:__LOC__ "%s not found from %s" (List.hd filenames)
269269
cwd
270270

271-
let find_config_dir cwd =
272-
find_root_filename ~cwd [Literals.rescript_json; Literals.bsconfig_json]
271+
let find_config_dir cwd = find_root_filename ~cwd [Literals.rescript_json]
273272

274273
let package_dir = lazy (find_config_dir (Lazy.force cwd))

compiler/ext/literals.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ let node_modules_length = String.length "node_modules"
7272

7373
let package_json = "package.json"
7474

75-
let bsconfig_json = "bsconfig.json"
76-
7775
let rescript_json = "rescript.json"
7876

7977
(* Name of the library file created for each external dependency. *)

compiler/frontend/ast_config.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ let process_directives str =
5252
| None -> Bs_syntaxerr.err item.pstr_loc Expect_string_literal)
5353
| _ -> ())
5454

55-
let rec iter_on_bs_config_str (x : Parsetree.structure) =
55+
let rec iter_on_config_str (x : Parsetree.structure) =
5656
match x with
5757
| [] -> ()
5858
| {pstr_desc = Pstr_attribute (({txt = "config"; loc}, payload) as attr)} :: _
@@ -61,14 +61,14 @@ let rec iter_on_bs_config_str (x : Parsetree.structure) =
6161
Ext_list.iter
6262
(Ast_payload.ident_or_record_as_config loc payload)
6363
(Ast_payload.table_dispatch !structural_config_table)
64-
| {pstr_desc = Pstr_attribute _} :: rest -> iter_on_bs_config_str rest
64+
| {pstr_desc = Pstr_attribute _} :: rest -> iter_on_config_str rest
6565
| _ :: _ -> ()
6666

6767
let process_str str =
68-
iter_on_bs_config_str str;
68+
iter_on_config_str str;
6969
process_directives str
7070

71-
let rec iter_on_bs_config_sig (x : Parsetree.signature) =
71+
let rec iter_on_config_sig (x : Parsetree.signature) =
7272
match x with
7373
| [] -> ()
7474
| {psig_desc = Psig_attribute (({txt = "config"; loc}, payload) as attr)} :: _
@@ -77,7 +77,7 @@ let rec iter_on_bs_config_sig (x : Parsetree.signature) =
7777
Ext_list.iter
7878
(Ast_payload.ident_or_record_as_config loc payload)
7979
(Ast_payload.table_dispatch !signature_config_table)
80-
| {psig_desc = Psig_attribute _} :: rest -> iter_on_bs_config_sig rest
80+
| {psig_desc = Psig_attribute _} :: rest -> iter_on_config_sig rest
8181
| _ :: _ -> ()
8282

83-
let process_sig s = iter_on_bs_config_sig s
83+
let process_sig s = iter_on_config_sig s

0 commit comments

Comments
 (0)