From 92f8b7736a435c34b2a305a7b096fc8049978ed9 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Sat, 20 Dec 2025 04:05:03 +0900 Subject: [PATCH] Drop bsconfig.json support --- analysis/reanalyze/src/Paths.ml | 12 +++-------- analysis/reanalyze/src/Reanalyze.ml | 2 +- analysis/src/FindFiles.ml | 6 +----- analysis/src/Packages.ml | 15 ++++--------- cli/common/bsb.js | 6 +----- compiler/bsb/bsb_build_util.ml | 4 +--- compiler/bsb/bsb_config_load.ml | 21 ++++--------------- compiler/bsb/bsb_config_load.mli | 3 +-- compiler/bsb/bsb_config_parse.ml | 4 +--- compiler/bsb/bsb_ninja_regen.ml | 6 ++---- compiler/bsb/bsb_ninja_regen.mli | 1 - compiler/bsb/bsb_parse_sources.ml | 2 +- compiler/bsb/bsb_world.ml | 3 +-- compiler/bsb_exe/rescript_main.ml | 8 +++---- compiler/ext/ext_path.ml | 3 +-- compiler/ext/literals.ml | 2 -- compiler/gentype/GenTypeConfig.ml | 8 ++----- compiler/gentype/Paths.ml | 6 +----- rewatch/CompilerConfigurationSpec.md | 2 +- rewatch/src/build/packages.rs | 8 +------ rewatch/src/helpers.rs | 2 +- .../warn_legacy_config/bsconfig.json | 8 ------- tests/build_tests/warn_legacy_config/input.js | 12 ----------- .../warn_legacy_config/src/demo.res | 1 - tools/bin/main.ml | 2 +- 25 files changed, 32 insertions(+), 115 deletions(-) delete mode 100644 tests/build_tests/warn_legacy_config/bsconfig.json delete mode 100644 tests/build_tests/warn_legacy_config/input.js delete mode 100644 tests/build_tests/warn_legacy_config/src/demo.res diff --git a/analysis/reanalyze/src/Paths.ml b/analysis/reanalyze/src/Paths.ml index 70b399932a..f1f6d7c27b 100644 --- a/analysis/reanalyze/src/Paths.ml +++ b/analysis/reanalyze/src/Paths.ml @@ -1,6 +1,5 @@ module StringMap = Map_string -let bsconfig = "bsconfig.json" let rescriptJson = "rescript.json" let readFile filename = @@ -14,8 +13,7 @@ let readFile filename = let rec findProjectRoot ~dir = let rescriptJsonFile = Filename.concat dir rescriptJson in - let bsconfigFile = Filename.concat dir bsconfig in - if Sys.file_exists rescriptJsonFile || Sys.file_exists bsconfigFile then dir + if Sys.file_exists rescriptJsonFile then dir else let parent = dir |> Filename.dirname in if parent = dir then ( @@ -83,10 +81,9 @@ module Config = struct | _ -> () (* Read the config from rescript.json and apply it to runConfig and suppress and unsuppress *) - let processBsconfig () = + let processConfig () = Lazy.force setReScriptProjectRoot; let rescriptFile = Filename.concat runConfig.projectRoot rescriptJson in - let bsconfigFile = Filename.concat runConfig.projectRoot bsconfig in let processText text = match Json.parse text with @@ -105,10 +102,7 @@ module Config = struct match readFile rescriptFile with | Some text -> processText text - | None -> ( - match readFile bsconfigFile with - | Some text -> processText text - | None -> ()) + | None -> () end (** diff --git a/analysis/reanalyze/src/Reanalyze.ml b/analysis/reanalyze/src/Reanalyze.ml index 006454247d..d3a5ad1bd2 100644 --- a/analysis/reanalyze/src/Reanalyze.ml +++ b/analysis/reanalyze/src/Reanalyze.ml @@ -368,7 +368,7 @@ let cli () = cmtRootRef := cmtRoot; analysisKindSet := true and setConfig () = - Paths.Config.processBsconfig (); + Paths.Config.processConfig (); analysisKindSet := true and setDCE cmtRoot = RunConfig.dce (); diff --git a/analysis/src/FindFiles.ml b/analysis/src/FindFiles.ml index a77e97ad1f..a18b57023c 100644 --- a/analysis/src/FindFiles.ml +++ b/analysis/src/FindFiles.ml @@ -241,7 +241,6 @@ let findDependencyFiles base config = (ModuleResolution.resolveNodeModulePath ~startPath:base name) (fun path -> let rescriptJsonPath = path /+ "rescript.json" in - let bsconfigJsonPath = path /+ "bsconfig.json" in let parseText text = match Json.parse text with @@ -272,10 +271,7 @@ let findDependencyFiles base config = match Files.readFile rescriptJsonPath with | Some text -> parseText text - | None -> ( - match Files.readFile bsconfigJsonPath with - | Some text -> parseText text - | None -> None)) + | None -> None) in match result with diff --git a/analysis/src/Packages.ml b/analysis/src/Packages.ml index bb455d925d..9b13b76a52 100644 --- a/analysis/src/Packages.ml +++ b/analysis/src/Packages.ml @@ -34,7 +34,6 @@ let getReScriptVersion () = let newBsPackage ~rootPath = let rescriptJson = Filename.concat rootPath "rescript.json" in - let bsconfigJson = Filename.concat rootPath "bsconfig.json" in let parseRaw raw = let libBs = @@ -192,23 +191,17 @@ let newBsPackage ~rootPath = match Files.readFile rescriptJson with | Some raw -> parseRaw raw - | None -> ( + | None -> Log.log ("Unable to read " ^ rescriptJson); - match Files.readFile bsconfigJson with - | Some raw -> parseRaw raw - | None -> - Log.log ("Unable to read " ^ bsconfigJson); - None) + None let findRoot ~uri packagesByRoot = let path = Uri.toPath uri in let rec loop path = if path = "/" then None else if Hashtbl.mem packagesByRoot path then Some (`Root path) - else if - Files.exists (Filename.concat path "rescript.json") - || Files.exists (Filename.concat path "bsconfig.json") - then Some (`Bs path) + else if Files.exists (Filename.concat path "rescript.json") then + Some (`Bs path) else let parent = Filename.dirname path in if parent = path then (* reached root *) None else loop parent diff --git a/cli/common/bsb.js b/cli/common/bsb.js index 8d0cf557ff..6397289765 100644 --- a/cli/common/bsb.js +++ b/cli/common/bsb.js @@ -190,11 +190,7 @@ function watch(args) { let webSocketHost = "localhost"; let webSocketPort = 9999; - let resConfig = "rescript.json"; - if (!fs.existsSync(resConfig)) { - resConfig = "bsconfig.json"; - } - + const resConfig = "rescript.json"; const sourcedirs = path.join("lib", "bs", ".sourcedirs.json"); let LAST_SUCCESS_BUILD_STAMP = 0; diff --git a/compiler/bsb/bsb_build_util.ml b/compiler/bsb/bsb_build_util.ml index 72e8ed5141..aae85b26e0 100644 --- a/compiler/bsb/bsb_build_util.ml +++ b/compiler/bsb/bsb_build_util.ml @@ -150,9 +150,7 @@ let pp_packages_rev ppf lst = let rec walk_all_deps_aux (visited : string Hash_string.t) (paths : string list) ~(top : top) (dir : string) (queue : _ Queue.t) = - match - Bsb_config_load.load_json ~per_proj_dir:dir ~warn_legacy_config:false - with + match Bsb_config_load.load_json ~per_proj_dir:dir with | _, Obj {map; loc} -> let cur_package_name = match Map_string.find_opt map Bsb_build_schemas.name with diff --git a/compiler/bsb/bsb_config_load.ml b/compiler/bsb/bsb_config_load.ml index be46965801..a389ba74f8 100644 --- a/compiler/bsb/bsb_config_load.ml +++ b/compiler/bsb/bsb_config_load.ml @@ -1,22 +1,9 @@ let ( // ) = Ext_path.combine -let load_json ~(per_proj_dir : string) ~(warn_legacy_config : bool) : - string * Ext_json_types.t = - let filename, abs, in_chan = - let filename = Literals.rescript_json in - let abs = per_proj_dir // filename in - match open_in abs with - | in_chan -> (filename, abs, in_chan) - | exception e -> ( - let filename = Literals.bsconfig_json in - let abs = per_proj_dir // filename in - match open_in abs with - | in_chan -> (filename, abs, in_chan) - | exception _ -> raise e (* forward error from rescript.json *)) - in - if warn_legacy_config && filename = Literals.bsconfig_json then - print_endline - "Warning: bsconfig.json is deprecated. Migrate it to rescript.json\n"; +let load_json ~(per_proj_dir : string) : string * Ext_json_types.t = + let filename = Literals.rescript_json in + let abs = per_proj_dir // filename in + let in_chan = open_in abs in match Ext_json_parse.parse_json_from_chan abs in_chan with | v -> close_in in_chan; diff --git a/compiler/bsb/bsb_config_load.mli b/compiler/bsb/bsb_config_load.mli index 7e8cd97857..c3b4f1840a 100644 --- a/compiler/bsb/bsb_config_load.mli +++ b/compiler/bsb/bsb_config_load.mli @@ -1,2 +1 @@ -val load_json : - per_proj_dir:string -> warn_legacy_config:bool -> string * Ext_json_types.t +val load_json : per_proj_dir:string -> string * Ext_json_types.t diff --git a/compiler/bsb/bsb_config_parse.ml b/compiler/bsb/bsb_config_parse.ml index a185c56c44..0bbf1a875d 100644 --- a/compiler/bsb/bsb_config_parse.ml +++ b/compiler/bsb/bsb_config_parse.ml @@ -323,8 +323,6 @@ let interpret_json ~(filename : string) ~(json : Ext_json_types.t) let deps_from_bsconfig () = let cwd = Bsb_global_paths.cwd in - match - Bsb_config_load.load_json ~per_proj_dir:cwd ~warn_legacy_config:false - with + match Bsb_config_load.load_json ~per_proj_dir:cwd with | _, Obj {map} -> (Bsb_package_specs.from_map ~cwd map, Bsb_jsx.from_map map) | _, _ -> assert false diff --git a/compiler/bsb/bsb_ninja_regen.ml b/compiler/bsb/bsb_ninja_regen.ml index 12e50c4b0b..0c7c1df5dc 100644 --- a/compiler/bsb/bsb_ninja_regen.ml +++ b/compiler/bsb/bsb_ninja_regen.ml @@ -31,7 +31,7 @@ let ( // ) = Ext_path.combine otherwise return Some info *) let regenerate_ninja ~(package_kind : Bsb_package_kind.t) ~forced ~per_proj_dir - ~warn_legacy_config ~warn_as_error : Bsb_config_types.t option = + ~warn_as_error : Bsb_config_types.t option = let lib_artifacts_dir = Bsb_config.lib_bs in let lib_bs_dir = per_proj_dir // lib_artifacts_dir in let output_deps = lib_bs_dir // bsdeps in @@ -39,9 +39,7 @@ let regenerate_ninja ~(package_kind : Bsb_package_kind.t) ~forced ~per_proj_dir Bsb_ninja_check.check ~package_kind ~per_proj_dir ~forced ~warn_as_error ~file:output_deps in - let config_filename, config_json = - Bsb_config_load.load_json ~per_proj_dir ~warn_legacy_config - in + let config_filename, config_json = Bsb_config_load.load_json ~per_proj_dir in match check_result with | Good -> None (* Fast path, no need regenerate ninja *) | Bsb_forced | Bsb_bsc_version_mismatch | Bsb_package_kind_inconsistent diff --git a/compiler/bsb/bsb_ninja_regen.mli b/compiler/bsb/bsb_ninja_regen.mli index 0af5766e57..34b9cd50aa 100644 --- a/compiler/bsb/bsb_ninja_regen.mli +++ b/compiler/bsb/bsb_ninja_regen.mli @@ -26,7 +26,6 @@ val regenerate_ninja : package_kind:Bsb_package_kind.t -> forced:bool -> per_proj_dir:string -> - warn_legacy_config:bool -> warn_as_error:string option -> Bsb_config_types.t option (** Regenerate ninja file by need based on [.bsdeps] diff --git a/compiler/bsb/bsb_parse_sources.ml b/compiler/bsb/bsb_parse_sources.ml index b829d616c3..05ab3046ab 100644 --- a/compiler/bsb/bsb_parse_sources.ml +++ b/compiler/bsb/bsb_parse_sources.ml @@ -403,7 +403,7 @@ and walk_source_dir_map (cxt : walk_cxt) sub_dirs_field = let clean_re_js root = match Ext_json_parse.parse_json_from_file - (Filename.concat root Literals.bsconfig_json) + (Filename.concat root Literals.rescript_json) with | Obj {map} -> let ignored_dirs = diff --git a/compiler/bsb/bsb_world.ml b/compiler/bsb/bsb_world.ml index 73c47f0fa6..a6f6c5fe0b 100644 --- a/compiler/bsb/bsb_world.ml +++ b/compiler/bsb/bsb_world.ml @@ -65,8 +65,7 @@ let make_world_deps cwd (config : Bsb_config_types.t option) let _config : _ option = Bsb_ninja_regen.regenerate_ninja ~package_kind:(Dependency {package_specs; jsx}) - ~per_proj_dir:proj_dir ~forced:false ~warn_legacy_config:false - ~warn_as_error:None + ~per_proj_dir:proj_dir ~forced:false ~warn_as_error:None in let command = {Bsb_unix.cmd = vendor_ninja; cwd = lib_bs_dir; args} diff --git a/compiler/bsb_exe/rescript_main.ml b/compiler/bsb_exe/rescript_main.ml index b28527a01d..c0b9fe80f5 100644 --- a/compiler/bsb_exe/rescript_main.ml +++ b/compiler/bsb_exe/rescript_main.ml @@ -172,7 +172,7 @@ let build_subcommand ~start argv argv_len = let config_opt = Bsb_ninja_regen.regenerate_ninja ~package_kind:Toplevel ~per_proj_dir:Bsb_global_paths.cwd ~forced:!force_regenerate - ~warn_legacy_config:true ~warn_as_error + ~warn_as_error in if not !no_deps_mode then Bsb_world.make_world_deps Bsb_global_paths.cwd config_opt ninja_args; @@ -204,8 +204,7 @@ let info_subcommand ~start argv = if !list_files then match Bsb_ninja_regen.regenerate_ninja ~package_kind:Toplevel - ~per_proj_dir:Bsb_global_paths.cwd ~forced:true - ~warn_legacy_config:true ~warn_as_error:None + ~per_proj_dir:Bsb_global_paths.cwd ~forced:true ~warn_as_error:None with | None -> assert false | Some {file_groups = {files}} -> @@ -229,8 +228,7 @@ let () = (* specialize this path which is used in watcher *) let config_opt = Bsb_ninja_regen.regenerate_ninja ~package_kind:Toplevel - ~per_proj_dir:Bsb_global_paths.cwd ~forced:false - ~warn_legacy_config:true ~warn_as_error:None + ~per_proj_dir:Bsb_global_paths.cwd ~forced:false ~warn_as_error:None in Bsb_world.make_world_deps Bsb_global_paths.cwd config_opt [||]; ninja_command_exit [||]) diff --git a/compiler/ext/ext_path.ml b/compiler/ext/ext_path.ml index 727ea43b5c..d43cff77f0 100644 --- a/compiler/ext/ext_path.ml +++ b/compiler/ext/ext_path.ml @@ -268,7 +268,6 @@ let rec find_root_filename ~cwd filenames = Ext_fmt.failwithf ~loc:__LOC__ "%s not found from %s" (List.hd filenames) cwd -let find_config_dir cwd = - find_root_filename ~cwd [Literals.rescript_json; Literals.bsconfig_json] +let find_config_dir cwd = find_root_filename ~cwd [Literals.rescript_json] let package_dir = lazy (find_config_dir (Lazy.force cwd)) diff --git a/compiler/ext/literals.ml b/compiler/ext/literals.ml index 2b469652ad..309996ab2d 100644 --- a/compiler/ext/literals.ml +++ b/compiler/ext/literals.ml @@ -72,8 +72,6 @@ let node_modules_length = String.length "node_modules" let package_json = "package.json" -let bsconfig_json = "bsconfig.json" - let rescript_json = "rescript.json" let build_ninja = "build.ninja" diff --git a/compiler/gentype/GenTypeConfig.ml b/compiler/gentype/GenTypeConfig.ml index 73925cc1d5..d24e2bc494 100644 --- a/compiler/gentype/GenTypeConfig.ml +++ b/compiler/gentype/GenTypeConfig.ml @@ -103,13 +103,9 @@ let set_debug ~gtconf = | _ -> () let compiler_config_file = "rescript.json" -let legacy_compiler_config_file = "bsconfig.json" let rec find_project_root ~dir = - if - Sys.file_exists (Filename.concat dir compiler_config_file) - || Sys.file_exists (Filename.concat dir legacy_compiler_config_file) - then dir + if Sys.file_exists (Filename.concat dir compiler_config_file) then dir else let parent = dir |> Filename.dirname in if parent = dir then ( @@ -184,7 +180,7 @@ let read_config ~get_config_file ~namespace = | Some external_stdlib -> external_stdlib in if !Debug.config then ( - Log_.item "Project roLiterals.bsconfig_jsonot: %s\n" project_root; + Log_.item "Project roLiterals.rescript_jsonot: %s\n" project_root; if bsb_project_root <> project_root then Log_.item "bsb project root: %s\n" bsb_project_root; Log_.item "Config module:%s shims:%d entries \n" diff --git a/compiler/gentype/Paths.ml b/compiler/gentype/Paths.ml index 89aeb8053b..d6dae2282f 100644 --- a/compiler/gentype/Paths.ml +++ b/compiler/gentype/Paths.ml @@ -89,10 +89,6 @@ let get_config_file ~project_root = let config = concat project_root Config.compiler_config_file in match config |> Sys.file_exists with | true -> Some config - | false -> ( - let config = concat project_root Config.legacy_compiler_config_file in - match config |> Sys.file_exists with - | true -> Some config - | false -> None) + | false -> None let read_config ~namespace = Config.read_config ~get_config_file ~namespace diff --git a/rewatch/CompilerConfigurationSpec.md b/rewatch/CompilerConfigurationSpec.md index e8e77df335..db73b6d147 100644 --- a/rewatch/CompilerConfigurationSpec.md +++ b/rewatch/CompilerConfigurationSpec.md @@ -1,6 +1,6 @@ ## ReScript build configuration -This document contains a list of all bsconfig parameters with remarks, and whether they are already implemented in rewatch. It is based on https://rescript-lang.org/docs/manual/latest/build-configuration-schema. +This document contains a list of all config parameters with remarks, and whether they are already implemented in rewatch. It is based on https://rescript-lang.org/docs/manual/latest/build-configuration-schema. | Parameter | JSON type | Remark | Implemented? | | --------------------- | ----------------------- | ------ | :----------: | diff --git a/rewatch/src/build/packages.rs b/rewatch/src/build/packages.rs index c9ab7ae65b..ed86edb365 100644 --- a/rewatch/src/build/packages.rs +++ b/rewatch/src/build/packages.rs @@ -245,13 +245,7 @@ fn get_source_dirs(source: config::Source, sub_path: Option) -> AHashSe pub fn read_config(package_dir: &Path) -> Result { let rescript_json_path = package_dir.join("rescript.json"); - let bsconfig_json_path = package_dir.join("bsconfig.json"); - - if Path::new(&rescript_json_path).exists() { - Config::new(&rescript_json_path) - } else { - Config::new(&bsconfig_json_path) - } + Config::new(&rescript_json_path) } pub fn read_dependency( diff --git a/rewatch/src/helpers.rs b/rewatch/src/helpers.rs index e269a12784..600dd34ab6 100644 --- a/rewatch/src/helpers.rs +++ b/rewatch/src/helpers.rs @@ -513,7 +513,7 @@ pub fn compute_file_hash(path: &Path) -> Option { } fn has_rescript_config(path: &Path) -> bool { - path.join("bsconfig.json").exists() || path.join("rescript.json").exists() + path.join("rescript.json").exists() } // traverse up the directory tree until we find a config.json, if not return None diff --git a/tests/build_tests/warn_legacy_config/bsconfig.json b/tests/build_tests/warn_legacy_config/bsconfig.json deleted file mode 100644 index ff8aa6b4b0..0000000000 --- a/tests/build_tests/warn_legacy_config/bsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "warn_legacy_config", - "version": "0.1.0", - "sources": { - "dir": "src", - "subdirs": true - } -} diff --git a/tests/build_tests/warn_legacy_config/input.js b/tests/build_tests/warn_legacy_config/input.js deleted file mode 100644 index e079332080..0000000000 --- a/tests/build_tests/warn_legacy_config/input.js +++ /dev/null @@ -1,12 +0,0 @@ -// @ts-check - -import * as assert from "node:assert"; -import { setup } from "#dev/process"; - -const { execBuild } = setup(import.meta.dirname); - -const output = await execBuild(); -assert.match( - output.stdout, - /^Warning: bsconfig.json is deprecated. Migrate it to rescript.json/, -); diff --git a/tests/build_tests/warn_legacy_config/src/demo.res b/tests/build_tests/warn_legacy_config/src/demo.res deleted file mode 100644 index 8d0b19151f..0000000000 --- a/tests/build_tests/warn_legacy_config/src/demo.res +++ /dev/null @@ -1 +0,0 @@ -let () = Js.log("Hello, ReScript") diff --git a/tools/bin/main.ml b/tools/bin/main.ml index cd810b5309..5937384ef3 100644 --- a/tools/bin/main.ml +++ b/tools/bin/main.ml @@ -87,7 +87,7 @@ let main () = (Error (Printf.sprintf "error: failed to load ReScript project at %s (missing \ - bsconfig.json/rescript.json?)" + rescript.json?)" rootPath)) | Some package -> let moduleNames =