diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63d2f8ad77..55632b2338 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,9 +93,6 @@ jobs: - name: Install npm packages run: yarn install - - name: Install testrepo deps - run: cd rewatch/testrepo && yarn install - - name: Install dependencies (Linux) if: runner.os == 'Linux' uses: awalsh128/cache-apt-pkgs-action@v1.4.3 diff --git a/CHANGELOG.md b/CHANGELOG.md index 9269351f0b..8d2d480dfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ #### :boom: Breaking Change - 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 +- Remove support for `bsconfig.json`. https://github.com/rescript-lang/rescript/pull/8187 - `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. - Remove `external-stdlib` configuration option from `rescript.json`. This option was rarely used and is no longer supported. diff --git a/analysis/reanalyze/src/Paths.ml b/analysis/reanalyze/src/Paths.ml index 906f198df9..05b17cefd0 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 ( @@ -84,10 +82,9 @@ module Config = struct | _ -> () (* Read the config from rescript.json and apply it to runConfig and suppress and unsuppress *) - let processBsconfig () = + let processConfig () = setProjectRootFromCwd (); let rescriptFile = Filename.concat runConfig.projectRoot rescriptJson in - let bsconfigFile = Filename.concat runConfig.projectRoot bsconfig in let processText text = match Json.parse text with @@ -106,10 +103,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 56c879341b..95b0fc5041 100644 --- a/analysis/reanalyze/src/Reanalyze.ml +++ b/analysis/reanalyze/src/Reanalyze.ml @@ -657,7 +657,7 @@ let parse_argv (argv : string array) : string option = cmtRootRef := cmtRoot; analysisKindSet := true and setConfig () = - Paths.Config.processBsconfig (); + Paths.Config.processConfig (); analysisKindSet := true and setDCE cmtRoot = RunConfig.dce (); @@ -787,7 +787,7 @@ let parse_argv (argv : string array) : string option = - reanalyze can be called from anywhere within the project Project root detection reuses the same logic as reanalyze config discovery: - walk up from a directory until we find rescript.json or bsconfig.json. *) + walk up from a directory until we find rescript.json. *) let cli () = let cmtRoot = parse_argv Sys.argv in runAnalysisAndReport ~cmtRoot diff --git a/analysis/reanalyze/src/ReanalyzeServer.ml b/analysis/reanalyze/src/ReanalyzeServer.ml index 85fbe4f20c..4db8480603 100644 --- a/analysis/reanalyze/src/ReanalyzeServer.ml +++ b/analysis/reanalyze/src/ReanalyzeServer.ml @@ -6,7 +6,7 @@ - reanalyze can be called from anywhere within the project Project root detection reuses the same logic as reanalyze config discovery: - walk up from a directory until we find rescript.json or bsconfig.json. *) + walk up from a directory until we find rescript.json. *) let default_socket_filename = ".rescript-reanalyze.sock" let project_root_from_dir (dir : string) : string option = 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/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 718110205d..2c1eeb6e5c 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" (* Name of the library file created for each external dependency. *) diff --git a/compiler/frontend/ast_config.ml b/compiler/frontend/ast_config.ml index e0f569965b..c05625b64e 100644 --- a/compiler/frontend/ast_config.ml +++ b/compiler/frontend/ast_config.ml @@ -52,7 +52,7 @@ let process_directives str = | None -> Bs_syntaxerr.err item.pstr_loc Expect_string_literal) | _ -> ()) -let rec iter_on_bs_config_str (x : Parsetree.structure) = +let rec iter_on_config_str (x : Parsetree.structure) = match x with | [] -> () | {pstr_desc = Pstr_attribute (({txt = "config"; loc}, payload) as attr)} :: _ @@ -61,14 +61,14 @@ let rec iter_on_bs_config_str (x : Parsetree.structure) = Ext_list.iter (Ast_payload.ident_or_record_as_config loc payload) (Ast_payload.table_dispatch !structural_config_table) - | {pstr_desc = Pstr_attribute _} :: rest -> iter_on_bs_config_str rest + | {pstr_desc = Pstr_attribute _} :: rest -> iter_on_config_str rest | _ :: _ -> () let process_str str = - iter_on_bs_config_str str; + iter_on_config_str str; process_directives str -let rec iter_on_bs_config_sig (x : Parsetree.signature) = +let rec iter_on_config_sig (x : Parsetree.signature) = match x with | [] -> () | {psig_desc = Psig_attribute (({txt = "config"; loc}, payload) as attr)} :: _ @@ -77,7 +77,7 @@ let rec iter_on_bs_config_sig (x : Parsetree.signature) = Ext_list.iter (Ast_payload.ident_or_record_as_config loc payload) (Ast_payload.table_dispatch !signature_config_table) - | {psig_desc = Psig_attribute _} :: rest -> iter_on_bs_config_sig rest + | {psig_desc = Psig_attribute _} :: rest -> iter_on_config_sig rest | _ :: _ -> () -let process_sig s = iter_on_bs_config_sig s +let process_sig s = iter_on_config_sig s diff --git a/compiler/gentype/GenTypeConfig.ml b/compiler/gentype/GenTypeConfig.ml index 4dcfffa458..67d6a32d46 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 ( @@ -238,9 +234,9 @@ let read_config ~get_config_file ~namespace = in let default_config = {default with project_root; bsb_project_root} in match get_config_file ~project_root with - | Some bs_config_file -> ( + | Some config_file -> ( try - let json = bs_config_file |> Ext_json_parse.parse_json_from_file in + let json = config_file |> Ext_json_parse.parse_json_from_file in match json with | Obj {map = bsconf} -> ( match bsconf |> get_opt "gentypeconfig" with 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 f3ec4b0889..cbaf1d4370 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/MonorepoSupport.md b/rewatch/MonorepoSupport.md index e58c589b9e..0638d96dba 100644 --- a/rewatch/MonorepoSupport.md +++ b/rewatch/MonorepoSupport.md @@ -14,7 +14,7 @@ All statements are derived from: | Term | Definition | |------|------------| -| **Package** | A folder containing `rescript.json` (or legacy `bsconfig.json`). Usually also has `package.json`. | +| **Package** | A folder containing `rescript.json`. Usually also has `package.json`. | | **Root config** | The `rescript.json` used for global build settings (JSX, output format, etc.). | | **Local package** | A package whose canonical path is inside the workspace AND not under any `node_modules` path component. | | **Current package** | The package where you ran `rescript build` or `rescript watch`. | @@ -41,7 +41,7 @@ There are **three effective modes**: - The root `rescript.json` should list workspace packages by name in `dependencies`/`dev-dependencies` ### 3. Monorepo Leaf Package -- A parent directory contains a `rescript.json` (or `bsconfig.json`) +- A parent directory contains a `rescript.json` - That parent config lists this package's name in its `dependencies` or `dev-dependencies` --- diff --git a/rewatch/src/build/packages.rs b/rewatch/src/build/packages.rs index 1779fd499e..81fb7f8bcf 100644 --- a/rewatch/src/build/packages.rs +++ b/rewatch/src/build/packages.rs @@ -246,13 +246,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/config.rs b/rewatch/src/config.rs index 0ac75ba6e5..9a8f72a09e 100644 --- a/rewatch/src/config.rs +++ b/rewatch/src/config.rs @@ -75,7 +75,7 @@ impl Source { } /// `to_qualified_without_children` takes a tree like structure of dependencies, coming in from - /// `bsconfig`, and turns it into a flat list. The main thing we extract here are the source + /// `rescript.json`, and turns it into a flat list. The main thing we extract here are the source /// folders, and optional subdirs, where potentially, the subdirs recurse or not. pub fn to_qualified_without_children(&self, sub_path: Option) -> PackageSource { match self { @@ -446,7 +446,7 @@ fn namespace_from_package_name(package_name: &str) -> String { } impl Config { - /// Try to convert a bsconfig from a certain path to a bsconfig struct + /// Try to convert a config from a certain path to a config struct pub fn new(path: &Path) -> Result { let read = fs::read_to_string(path)?; let mut config = Config::new_from_json_string(&read)?; @@ -454,7 +454,7 @@ impl Config { Ok(config) } - /// Try to convert a bsconfig from a string to a bsconfig struct + /// Try to convert a config from a string to a config struct pub fn new_from_json_string(config_str: &str) -> Result { let mut deserializer = serde_json::Deserializer::from_str(config_str); let mut tracker = serde_path_to_error::Track::new(); 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/rewatch/tests/suite.sh b/rewatch/tests/suite.sh index 08af67d5c3..b484df0ee0 100755 --- a/rewatch/tests/suite.sh +++ b/rewatch/tests/suite.sh @@ -29,7 +29,7 @@ fi source ./utils.sh bold "Yarn install" -(cd ../testrepo && yarn) +(cd ../testrepo && yarn && cp node_modules/rescript-nodejs/bsconfig.json node_modules/rescript-nodejs/rescript.json) bold "Rescript version" (cd ../testrepo && ./node_modules/.bin/rescript --version) diff --git a/tests/build_tests/warn_legacy_config/input.js b/tests/build_tests/warn_legacy_config/input.js index ab47cb886f..86d9307770 100644 --- a/tests/build_tests/warn_legacy_config/input.js +++ b/tests/build_tests/warn_legacy_config/input.js @@ -7,5 +7,5 @@ const { execBuild, execClean } = setup(import.meta.dirname); const output = await execBuild(); assert.notEqual(output.status, 0); -assert.match(output.stderr, /no package\.json or rescript\.json file/i); +assert.match(output.stderr, /could not read rescript\.json/i); await execClean(); diff --git a/tests/tests/src/test_literals.mjs b/tests/tests/src/test_literals.mjs index 4554d9b062..456a81d576 100644 --- a/tests/tests/src/test_literals.mjs +++ b/tests/tests/src/test_literals.mjs @@ -5,11 +5,8 @@ let node_modules_length = "node_modules".length; let node_modules = "node_modules"; -let bsconfig_json = "bsconfig.json"; - export { node_modules, node_modules_length, - bsconfig_json, } /* node_modules_length Not a pure module */ diff --git a/tests/tests/src/test_literals.res b/tests/tests/src/test_literals.res index 1ce0973ff6..2a52f7dcdd 100644 --- a/tests/tests/src/test_literals.res +++ b/tests/tests/src/test_literals.res @@ -1,5 +1,3 @@ /** nodejs */ let node_modules = "node_modules" let node_modules_length = String.length("node_modules") - -let bsconfig_json = "bsconfig.json" diff --git a/tools/bin/main.ml b/tools/bin/main.ml index b14f25f5a4..130ce24ac7 100644 --- a/tools/bin/main.ml +++ b/tools/bin/main.ml @@ -88,7 +88,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 =