From 643acb5881b7a61e7346f6eaa2d10976eeb80875 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Mon, 5 May 2025 10:21:41 +0200 Subject: [PATCH] bsconfig.json -> rescript.json in error messages + comments --- analysis/reanalyze/src/Paths.ml | 2 +- analysis/reanalyze/src/Reanalyze.ml | 4 +--- analysis/src/CompletionDecorators.ml | 2 +- compiler/bsb/bsb_build_util.ml | 2 +- compiler/bsb/bsb_build_util.mli | 2 +- compiler/bsb/bsb_exception.ml | 6 +++--- compiler/bsb/bsb_ninja_rule.mli | 4 ++-- compiler/bsb/bsb_pkg.ml | 4 ---- compiler/bsb/bsb_watcher_gen.mli | 4 ++-- compiler/bsb_exe/rescript_main.ml | 4 ++-- compiler/jsoo/jsoo_playground_main.ml | 2 +- compiler/ml/typetexp.ml | 4 ++-- docs/JSXV4.md | 2 +- rewatch/tests/snapshots/remove-file.txt | 4 ++-- .../tests/snapshots/rename-file-internal-dep-namespace.txt | 4 ++-- rewatch/tests/snapshots/rename-file-internal-dep.txt | 4 ++-- runtime/Belt.res | 2 +- tests/analysis_tests/tests/src/expected/Completion.res.txt | 4 ++-- tests/build_tests/case/input.js | 6 +++--- tests/build_tests/case2/input.js | 6 +++--- .../build_tests/super_errors/expected/modules1.res.expected | 4 ++-- tests/build_tests/weird_deps/input.js | 2 +- tests/build_tests/weird_devdeps/input.js | 2 +- 23 files changed, 37 insertions(+), 43 deletions(-) diff --git a/analysis/reanalyze/src/Paths.ml b/analysis/reanalyze/src/Paths.ml index 45341f1042..a3471e31c4 100644 --- a/analysis/reanalyze/src/Paths.ml +++ b/analysis/reanalyze/src/Paths.ml @@ -81,7 +81,7 @@ module Config = struct | Some False -> RunConfig.transitive false | _ -> () - (* Read the config from rescript.json/bsconfig.json and apply it to runConfig and suppress and unsuppress *) + (* Read the config from rescript.json and apply it to runConfig and suppress and unsuppress *) let processBsconfig () = Lazy.force setReScriptProjectRoot; let rescriptFile = Filename.concat runConfig.projectRoot rescriptJson in diff --git a/analysis/reanalyze/src/Reanalyze.ml b/analysis/reanalyze/src/Reanalyze.ml index e52a9c1f46..7378264908 100644 --- a/analysis/reanalyze/src/Reanalyze.ml +++ b/analysis/reanalyze/src/Reanalyze.ml @@ -139,9 +139,7 @@ let cli () = "root_path Run all the analyses for all the .cmt files under the root \ path" ); ("-ci", Unit (fun () -> Cli.ci := true), "Internal flag for use in CI"); - ( "-config", - Unit setConfig, - "Read the analysis mode from rescript.json/bsconfig.json" ); + ("-config", Unit setConfig, "Read the analysis mode from rescript.json"); ("-dce", Unit (fun () -> setDCE None), "Eperimental DCE"); ("-debug", Unit (fun () -> Cli.debug := true), "Print debug information"); ( "-dce-cmt", diff --git a/analysis/src/CompletionDecorators.ml b/analysis/src/CompletionDecorators.ml index f43e5e16b3..c3eae9debc 100644 --- a/analysis/src/CompletionDecorators.ml +++ b/analysis/src/CompletionDecorators.ml @@ -164,7 +164,7 @@ Example `@raises(Exn)` or `@raises([E1, E2, E3])` for multiple exceptions. You will need this decorator whenever you want to use a ReScript / React component in ReScript JSX expressions. -Note: The `@react.component` decorator requires the `jsx` config to be set in your `rescript.json`/`bsconfig.json` to enable the required React transformations. +Note: The `@react.component` decorator requires the `jsx` config to be set in your `rescript.json` to enable the required React transformations. [Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#react-component-decorator).|}; ] ); diff --git a/compiler/bsb/bsb_build_util.ml b/compiler/bsb/bsb_build_util.ml index 36f5c9a935..3121c304e1 100644 --- a/compiler/bsb/bsb_build_util.ml +++ b/compiler/bsb/bsb_build_util.ml @@ -172,7 +172,7 @@ let rec walk_all_deps_aux (visited : string Hash_string.t) (paths : string list) "package name is expected to be %s but got %s" s str); str | Some _ | None -> - Bsb_exception.errorf ~loc "package name missing in %s/bsconfig.json" dir + Bsb_exception.errorf ~loc "package name missing in %s/rescript.json" dir in if Ext_list.mem_string paths cur_package_name then ( Bsb_log.error "@{Cyclic dependencies in package stack@}@."; diff --git a/compiler/bsb/bsb_build_util.mli b/compiler/bsb/bsb_build_util.mli index a0f2aa6375..8ddf6b6531 100644 --- a/compiler/bsb/bsb_build_util.mli +++ b/compiler/bsb/bsb_build_util.mli @@ -57,7 +57,7 @@ val include_dirs_by : 'a list -> ('a -> string) -> string val mkp : string -> unit (* The path of [bsc] and [bsdep] is normalized so that the invokation of [./compiler/bin/bsb.exe] - and [bsb.exe] (combined with a dirty bsconfig.json) will not trigger unnecessary rebuild. + and [bsb.exe] (combined with a dirty rescript.json) will not trigger unnecessary rebuild. The location of [bsc] and [bsdep] is configured by the combination of [Sys.executable_name] and [cwd]. diff --git a/compiler/bsb/bsb_exception.ml b/compiler/bsb/bsb_exception.ml index 7662783ef1..f85c8417e8 100644 --- a/compiler/bsb/bsb_exception.ml +++ b/compiler/bsb/bsb_exception.ml @@ -49,14 +49,14 @@ let print (fmt : Format.formatter) (x : error) = let name = Bsb_pkg_types.to_string name in if Ext_string.equal name !Bs_version.package_name then Format.fprintf fmt - "File \"bsconfig.json\", line 1\n\ + "File \"rescript.json\", line 1\n\ @{Error:@} package @{%s@} is not found\n\ It's the basic, required package. If you have it installed globally,\n\ Please run `npm link rescript` to make it available" name else Format.fprintf fmt - "File \"bsconfig.json\", line 1\n\ + "File \"rescript.json\", line 1\n\ @{Error:@} package @{%s@} not found or built\n\ - Did you install it?" name @@ -68,7 +68,7 @@ let print (fmt : Format.formatter) (x : error) = https://rescript-lang.org/docs/manual/latest/build-configuration-schema" pos.pos_fname pos.pos_lnum s | Invalid_spec s -> - Format.fprintf fmt "@{Error: Invalid bsconfig.json %s@}" s + Format.fprintf fmt "@{Error: Invalid rescript.json: %s@}" s let conflict_module modname dir1 dir2 = Error (Conflict_module (modname, dir1, dir2)) diff --git a/compiler/bsb/bsb_ninja_rule.mli b/compiler/bsb/bsb_ninja_rule.mli index 65efad6781..9562c57acc 100644 --- a/compiler/bsb/bsb_ninja_rule.mli +++ b/compiler/bsb/bsb_ninja_rule.mli @@ -56,12 +56,12 @@ type builtin = { (** rules are generally composed of built-in rules and customized rules, there are two design choices: 1. respect custom rules with the same name, then we need adjust our built-in rules dynamically in case the conflict. - 2. respect our built-in rules, then we only need re-load custom rules for each bsconfig.json + 2. respect our built-in rules, then we only need re-load custom rules for each rescript.json *) type command = string -(* Since now we generate ninja files per bsconfig.json in a single process, +(* Since now we generate ninja files per rescript.json in a single process, we must make sure it is re-entrant *) val make_custom_rules : diff --git a/compiler/bsb/bsb_pkg.ml b/compiler/bsb/bsb_pkg.ml index e542c7d271..47a3f22bc0 100644 --- a/compiler/bsb/bsb_pkg.ml +++ b/compiler/bsb/bsb_pkg.ml @@ -26,10 +26,6 @@ let ( // ) = Filename.concat type t = Bsb_pkg_types.t -(* TODO: be more restrict - [bsconfig.json] does not always make sense, - when resolving [ppx-flags] -*) let make_sub_path (x : t) : string = Literals.node_modules // Bsb_pkg_types.to_string x diff --git a/compiler/bsb/bsb_watcher_gen.mli b/compiler/bsb/bsb_watcher_gen.mli index 6e2b989343..1d13f3cb7f 100644 --- a/compiler/bsb/bsb_watcher_gen.mli +++ b/compiler/bsb/bsb_watcher_gen.mli @@ -24,10 +24,10 @@ val generate_sourcedirs_meta : name:string -> Bsb_file_groups.t -> unit (** This module try to generate some meta data so that - everytime [bsconfig.json] is reload, we can re-read + everytime [rescript.json] is reloaded, we can re-read such meta data changes in the watcher. - Another way of doing it is processing [bsconfig.json] + Another way of doing it is processing [rescript.json] directly in [watcher] but that would mean the duplication of logic in [bsb] and [bsb_watcher] *) diff --git a/compiler/bsb_exe/rescript_main.ml b/compiler/bsb_exe/rescript_main.ml index d066de72b9..e8d517d4e6 100644 --- a/compiler/bsb_exe/rescript_main.ml +++ b/compiler/bsb_exe/rescript_main.ml @@ -135,8 +135,8 @@ let build_subcommand ~start argv argv_len = ( "-regen", unit_set_spec force_regenerate, "*internal* \n\ - Always regenerate build.ninja no matter bsconfig.json is changed or \ - not" ); + Always regenerate build.ninja no matter if rescript.json is changed \ + or not" ); ( "-no-deps", unit_set_spec no_deps_mode, "*internal* Needed for watcher to build without dependencies on file \ diff --git a/compiler/jsoo/jsoo_playground_main.ml b/compiler/jsoo/jsoo_playground_main.ml index d1de5cad1c..9c1ee69d1b 100644 --- a/compiler/jsoo/jsoo_playground_main.ml +++ b/compiler/jsoo/jsoo_playground_main.ml @@ -45,7 +45,7 @@ * ----------------------------- * Version History: * v2: Remove refmt support (removes compiler.reason apis) * v3: Switched to Uncurried mode by default (requires third party packages - to be built with uncurried: true in bsconfig.json). Also added + to be built with uncurried: true in rescript.json). Also added `config.uncurried` to the BundleConfig. * v4: Added `config.open_modules` to the BundleConfig to enable implicitly opened * modules in the playground. diff --git a/compiler/ml/typetexp.ml b/compiler/ml/typetexp.ml index fef7215284..a6940ff2b5 100644 --- a/compiler/ml/typetexp.ml +++ b/compiler/ml/typetexp.ml @@ -889,9 +889,9 @@ let report_error env ppf = function "@[@{The module or file %a can't be found.@}@,\ @[- If it's a third-party dependency:@,\ - Did you add it to the \"bs-dependencies\" or \ - \"bs-dev-dependencies\" in bsconfig.json?@]@,\ + \"bs-dev-dependencies\" in rescript.json?@]@,\ - Did you include the file's directory to the \"sources\" in \ - bsconfig.json?@," + rescript.json?@," Printtyp.longident lid); super_spellcheck ppf Env.fold_modules env lid |> ignore | Unbound_constructor lid -> diff --git a/docs/JSXV4.md b/docs/JSXV4.md index ce69c4e00c..468643081f 100644 --- a/docs/JSXV4.md +++ b/docs/JSXV4.md @@ -5,7 +5,7 @@ The V4 representation is part of the spec, so `@react.component` is effectively ## Turn On V4 -To build an entire project in V4 mode, including all its dependencies, use the new `"jsx"` configuration in `bsconfig.json` instead of the old `"reason"`: +To build an entire project in V4 mode, including all its dependencies, use the new `"jsx"` configuration in `rescript.json` instead of the old `"reason"`: ```json "jsx": { "version": 4 } diff --git a/rewatch/tests/snapshots/remove-file.txt b/rewatch/tests/snapshots/remove-file.txt index 344d8d3d42..402cff956b 100644 --- a/rewatch/tests/snapshots/remove-file.txt +++ b/rewatch/tests/snapshots/remove-file.txt @@ -22,8 +22,8 @@ ERROR: The module or file Dep02 can't be found. - If it's a third-party dependency: - - Did you add it to the "bs-dependencies" or "bs-dev-dependencies" in bsconfig.json? - - Did you include the file's directory to the "sources" in bsconfig.json? + - Did you add it to the "bs-dependencies" or "bs-dev-dependencies" in rescript.json? + - Did you include the file's directory to the "sources" in rescript.json? diff --git a/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt b/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt index b251dbce0a..bafc2ba959 100644 --- a/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt +++ b/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt @@ -20,8 +20,8 @@ ERROR: The module or file Other_module can't be found. - If it's a third-party dependency: - - Did you add it to the "bs-dependencies" or "bs-dev-dependencies" in bsconfig.json? - - Did you include the file's directory to the "sources" in bsconfig.json? + - Did you add it to the "bs-dependencies" or "bs-dev-dependencies" in rescript.json? + - Did you include the file's directory to the "sources" in rescript.json? Hint: Did you mean Other_module2? diff --git a/rewatch/tests/snapshots/rename-file-internal-dep.txt b/rewatch/tests/snapshots/rename-file-internal-dep.txt index 4e1d142c37..69e10d6ca2 100644 --- a/rewatch/tests/snapshots/rename-file-internal-dep.txt +++ b/rewatch/tests/snapshots/rename-file-internal-dep.txt @@ -22,8 +22,8 @@ ERROR: The module or file InternalDep can't be found. - If it's a third-party dependency: - - Did you add it to the "bs-dependencies" or "bs-dev-dependencies" in bsconfig.json? - - Did you include the file's directory to the "sources" in bsconfig.json? + - Did you add it to the "bs-dependencies" or "bs-dev-dependencies" in rescript.json? + - Did you include the file's directory to the "sources" in rescript.json? diff --git a/runtime/Belt.res b/runtime/Belt.res index 7604a370d9..d866766c12 100644 --- a/runtime/Belt.res +++ b/runtime/Belt.res @@ -56,7 +56,7 @@ If you want to open Belt globally for all files in your project instead, you can } ``` -into your `bsconfig.json`. +into your `rescript.json`. **Note**: this is the **only** `open` we encourage. diff --git a/tests/analysis_tests/tests/src/expected/Completion.res.txt b/tests/analysis_tests/tests/src/expected/Completion.res.txt index 90f33b561c..7c7f2563bf 100644 --- a/tests/analysis_tests/tests/src/expected/Completion.res.txt +++ b/tests/analysis_tests/tests/src/expected/Completion.res.txt @@ -752,7 +752,7 @@ Resolved opens 1 Stdlib "kind": 4, "tags": [], "detail": "", - "documentation": {"kind": "markdown", "value": "The `@react.component` decorator is used to annotate functions that are RescriptReact components.\n\nYou will need this decorator whenever you want to use a ReScript / React component in ReScript JSX expressions.\n\nNote: The `@react.component` decorator requires the `jsx` config to be set in your `rescript.json`/`bsconfig.json` to enable the required React transformations.\n\n[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#react-component-decorator)."}, + "documentation": {"kind": "markdown", "value": "The `@react.component` decorator is used to annotate functions that are RescriptReact components.\n\nYou will need this decorator whenever you want to use a ReScript / React component in ReScript JSX expressions.\n\nNote: The `@react.component` decorator requires the `jsx` config to be set in your `rescript.json` to enable the required React transformations.\n\n[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#react-component-decorator)."}, "insertTextFormat": 2 }] @@ -768,7 +768,7 @@ Resolved opens 1 Stdlib "kind": 4, "tags": [], "detail": "", - "documentation": {"kind": "markdown", "value": "The `@react.component` decorator is used to annotate functions that are RescriptReact components.\n\nYou will need this decorator whenever you want to use a ReScript / React component in ReScript JSX expressions.\n\nNote: The `@react.component` decorator requires the `jsx` config to be set in your `rescript.json`/`bsconfig.json` to enable the required React transformations.\n\n[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#react-component-decorator)."}, + "documentation": {"kind": "markdown", "value": "The `@react.component` decorator is used to annotate functions that are RescriptReact components.\n\nYou will need this decorator whenever you want to use a ReScript / React component in ReScript JSX expressions.\n\nNote: The `@react.component` decorator requires the `jsx` config to be set in your `rescript.json` to enable the required React transformations.\n\n[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#react-component-decorator)."}, "insertTextFormat": 2 }] diff --git a/tests/build_tests/case/input.js b/tests/build_tests/case/input.js index f91b89964c..52187b7a34 100644 --- a/tests/build_tests/case/input.js +++ b/tests/build_tests/case/input.js @@ -8,11 +8,11 @@ const { stderr } = await execBuild(); if ( ![ - "Error: Invalid bsconfig.json implementation and interface have different path names or different cases src/demo vs src/Demo\n", + "Error: Invalid rescript.json: implementation and interface have different path names or different cases src/demo vs src/Demo\n", // Windows: path separator - "Error: Invalid bsconfig.json implementation and interface have different path names or different cases src\\demo vs src\\Demo\n", + "Error: Invalid rescript.json: implementation and interface have different path names or different cases src\\demo vs src\\Demo\n", // Linux: files are parsed in different order - "Error: Invalid bsconfig.json implementation and interface have different path names or different cases src/Demo vs src/demo\n", + "Error: Invalid rescript.json: implementation and interface have different path names or different cases src/Demo vs src/demo\n", ].includes(normalizeNewlines(stderr)) ) { assert.fail(stderr); diff --git a/tests/build_tests/case2/input.js b/tests/build_tests/case2/input.js index 2b5299779f..6daed5d4ee 100644 --- a/tests/build_tests/case2/input.js +++ b/tests/build_tests/case2/input.js @@ -10,11 +10,11 @@ const { stderr } = await execBuild(); if ( ![ - "Error: Invalid bsconfig.json implementation and interface have different path names or different cases src/X vs src/x\n", + "Error: Invalid rescript.json: implementation and interface have different path names or different cases src/X vs src/x\n", // Windows: path separator - "Error: Invalid bsconfig.json implementation and interface have different path names or different cases src\\X vs src\\x\n", + "Error: Invalid rescript.json: implementation and interface have different path names or different cases src\\X vs src\\x\n", // Linux: files are parsed in different order - "Error: Invalid bsconfig.json implementation and interface have different path names or different cases src/x vs src/X\n", + "Error: Invalid rescript.json: implementation and interface have different path names or different cases src/x vs src/X\n", ].includes(normalizeNewlines(stderr)) ) { assert.fail(stderr); diff --git a/tests/build_tests/super_errors/expected/modules1.res.expected b/tests/build_tests/super_errors/expected/modules1.res.expected index 309f16af3d..da7b974176 100644 --- a/tests/build_tests/super_errors/expected/modules1.res.expected +++ b/tests/build_tests/super_errors/expected/modules1.res.expected @@ -7,5 +7,5 @@ The module or file Foo can't be found. - If it's a third-party dependency: - - Did you add it to the "bs-dependencies" or "bs-dev-dependencies" in bsconfig.json? - - Did you include the file's directory to the "sources" in bsconfig.json? \ No newline at end of file + - Did you add it to the "bs-dependencies" or "bs-dev-dependencies" in rescript.json? + - Did you include the file's directory to the "sources" in rescript.json? \ No newline at end of file diff --git a/tests/build_tests/weird_deps/input.js b/tests/build_tests/weird_deps/input.js index b5d4af7317..a2b1f4a5e0 100644 --- a/tests/build_tests/weird_deps/input.js +++ b/tests/build_tests/weird_deps/input.js @@ -13,7 +13,7 @@ if (out.stdout !== "") { assert.equal( normalizeNewlines(out.stderr), [ - 'File "bsconfig.json", line 1', + 'File "rescript.json", line 1', "Error: package weird not found or built", "- Did you install it?", "", diff --git a/tests/build_tests/weird_devdeps/input.js b/tests/build_tests/weird_devdeps/input.js index fa9afcce6c..46371e50bb 100644 --- a/tests/build_tests/weird_devdeps/input.js +++ b/tests/build_tests/weird_devdeps/input.js @@ -13,7 +13,7 @@ if (out.stdout !== "") { assert.equal( out.stderr, [ - 'File "bsconfig.json", line 1', + 'File "rescript.json", line 1', "Error: package weird not found or built", "- Did you install it?", "",