Skip to content

Commit e80bea1

Browse files
committed
Drop bsconfig.json support
1 parent 5c5cdba commit e80bea1

File tree

25 files changed

+32
-115
lines changed

25 files changed

+32
-115
lines changed

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 (
@@ -83,10 +81,9 @@ module Config = struct
8381
| _ -> ()
8482

8583
(* Read the config from rescript.json and apply it to runConfig and suppress and unsuppress *)
86-
let processBsconfig () =
84+
let processConfig () =
8785
Lazy.force setReScriptProjectRoot;
8886
let rescriptFile = Filename.concat runConfig.projectRoot rescriptJson in
89-
let bsconfigFile = Filename.concat runConfig.projectRoot bsconfig in
9087

9188
let processText text =
9289
match Json.parse text with
@@ -105,10 +102,7 @@ module Config = struct
105102

106103
match readFile rescriptFile with
107104
| Some text -> processText text
108-
| None -> (
109-
match readFile bsconfigFile with
110-
| Some text -> processText text
111-
| None -> ())
105+
| None -> ()
112106
end
113107

114108
(**

analysis/reanalyze/src/Reanalyze.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ let cli () =
613613
cmtRootRef := cmtRoot;
614614
analysisKindSet := true
615615
and setConfig () =
616-
Paths.Config.processBsconfig ();
616+
Paths.Config.processConfig ();
617617
analysisKindSet := true
618618
and setDCE cmtRoot =
619619
RunConfig.dce ();

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

cli/common/bsb.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,7 @@ function watch(args) {
190190
let webSocketHost = "localhost";
191191
let webSocketPort = 9999;
192192

193-
let resConfig = "rescript.json";
194-
if (!fs.existsSync(resConfig)) {
195-
resConfig = "bsconfig.json";
196-
}
197-
193+
const resConfig = "rescript.json";
198194
const sourcedirs = path.join("lib", "bs", ".sourcedirs.json");
199195

200196
let LAST_SUCCESS_BUILD_STAMP = 0;

compiler/bsb/bsb_build_util.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,7 @@ let pp_packages_rev ppf lst =
150150

151151
let rec walk_all_deps_aux (visited : string Hash_string.t) (paths : string list)
152152
~(top : top) (dir : string) (queue : _ Queue.t) =
153-
match
154-
Bsb_config_load.load_json ~per_proj_dir:dir ~warn_legacy_config:false
155-
with
153+
match Bsb_config_load.load_json ~per_proj_dir:dir with
156154
| _, Obj {map; loc} ->
157155
let cur_package_name =
158156
match Map_string.find_opt map Bsb_build_schemas.name with

compiler/bsb/bsb_config_load.ml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
11
let ( // ) = Ext_path.combine
22

3-
let load_json ~(per_proj_dir : string) ~(warn_legacy_config : bool) :
4-
string * Ext_json_types.t =
5-
let filename, abs, in_chan =
6-
let filename = Literals.rescript_json in
7-
let abs = per_proj_dir // filename in
8-
match open_in abs with
9-
| in_chan -> (filename, abs, in_chan)
10-
| exception e -> (
11-
let filename = Literals.bsconfig_json in
12-
let abs = per_proj_dir // filename in
13-
match open_in abs with
14-
| in_chan -> (filename, abs, in_chan)
15-
| exception _ -> raise e (* forward error from rescript.json *))
16-
in
17-
if warn_legacy_config && filename = Literals.bsconfig_json then
18-
print_endline
19-
"Warning: bsconfig.json is deprecated. Migrate it to rescript.json\n";
3+
let load_json ~(per_proj_dir : string) : string * Ext_json_types.t =
4+
let filename = Literals.rescript_json in
5+
let abs = per_proj_dir // filename in
6+
let in_chan = open_in abs in
207
match Ext_json_parse.parse_json_from_chan abs in_chan with
218
| v ->
229
close_in in_chan;

compiler/bsb/bsb_config_load.mli

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
val load_json :
2-
per_proj_dir:string -> warn_legacy_config:bool -> string * Ext_json_types.t
1+
val load_json : per_proj_dir:string -> string * Ext_json_types.t

compiler/bsb/bsb_config_parse.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,6 @@ let interpret_json ~(filename : string) ~(json : Ext_json_types.t)
323323

324324
let deps_from_bsconfig () =
325325
let cwd = Bsb_global_paths.cwd in
326-
match
327-
Bsb_config_load.load_json ~per_proj_dir:cwd ~warn_legacy_config:false
328-
with
326+
match Bsb_config_load.load_json ~per_proj_dir:cwd with
329327
| _, Obj {map} -> (Bsb_package_specs.from_map ~cwd map, Bsb_jsx.from_map map)
330328
| _, _ -> assert false

compiler/bsb/bsb_ninja_regen.ml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,15 @@ let ( // ) = Ext_path.combine
3131
otherwise return Some info
3232
*)
3333
let regenerate_ninja ~(package_kind : Bsb_package_kind.t) ~forced ~per_proj_dir
34-
~warn_legacy_config ~warn_as_error : Bsb_config_types.t option =
34+
~warn_as_error : Bsb_config_types.t option =
3535
let lib_artifacts_dir = Bsb_config.lib_bs in
3636
let lib_bs_dir = per_proj_dir // lib_artifacts_dir in
3737
let output_deps = lib_bs_dir // bsdeps in
3838
let check_result =
3939
Bsb_ninja_check.check ~package_kind ~per_proj_dir ~forced ~warn_as_error
4040
~file:output_deps
4141
in
42-
let config_filename, config_json =
43-
Bsb_config_load.load_json ~per_proj_dir ~warn_legacy_config
44-
in
42+
let config_filename, config_json = Bsb_config_load.load_json ~per_proj_dir in
4543
match check_result with
4644
| Good -> None (* Fast path, no need regenerate ninja *)
4745
| Bsb_forced | Bsb_bsc_version_mismatch | Bsb_package_kind_inconsistent

0 commit comments

Comments
 (0)