diff --git a/CHANGELOG.md b/CHANGELOG.md index 95de0280cf..a4debfd5cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Deprecate JSX 3 https://github.com/rescript-lang/rescript-compiler/pull/7042 - Deprecate js_cast.res https://github.com/rescript-lang/rescript-compiler/pull/7074 +- Deprecate top-level `"suffix"` option in `rescript.json`. https://github.com/rescript-lang/rescript-compiler/pull/7056 # 11.1.4 diff --git a/docs/docson/build-schema.json b/docs/docson/build-schema.json index c0139a7e9f..f8b6328497 100644 --- a/docs/docson/build-schema.json +++ b/docs/docson/build-schema.json @@ -5,10 +5,6 @@ "enum": ["esmodule", "commonjs", "es6", "es6-global"], "description": "es6 and es6-global are deprecated. Default: commonjs." }, - "suffix-spec": { - "type": "string", - "description": "Suffix of generated js files. Default: .js. May contain letters, digits, \"-\", \"_\" and \".\" and must end with .js, .mjs or .cjs." - }, "module-format-object": { "type": "object", "properties": { @@ -20,7 +16,8 @@ "description": "Default: false." }, "suffix": { - "$ref": "#/definitions/suffix-spec" + "type": "string", + "description": "Suffix of generated js files. Default: .js. May contain letters, digits, \"-\", \"_\" and \".\" and must end with .js, .mjs or .cjs." } }, "required": ["module"] @@ -487,9 +484,6 @@ }, "description": "(Not needed usually) external include directories, which will be applied `-I` to all compilation units" }, - "suffix": { - "$ref": "#/definitions/suffix-spec" - }, "reanalyze": { "$ref": "#/definitions/reanalyze", "description": "Configure reanalyze, a static code analysis tool for ReScript." diff --git a/jscomp/bsb/bsb_package_specs.ml b/jscomp/bsb/bsb_package_specs.ml index bcb88c90ac..8bbecfa2b1 100644 --- a/jscomp/bsb/bsb_package_specs.ml +++ b/jscomp/bsb/bsb_package_specs.ml @@ -43,14 +43,17 @@ let bad_module_format_message_exn ~loc format = of: %s or %s" format Literals.esmodule Literals.commonjs +let deprecated_option ~loc x message = + let loc_end = + {loc with Lexing.pos_cnum = loc.Lexing.pos_cnum + String.length x} + in + let loc = {Warnings.loc_start = loc; loc_end; loc_ghost = false} in + Location.deprecated loc message + let supported_format (x : string) loc : Ext_module_system.t = let _ = if x = Literals.es6 || x = Literals.es6_global then - let loc_end = - {loc with Lexing.pos_cnum = loc.Lexing.pos_cnum + String.length x} - in - let loc = {Warnings.loc_start = loc; loc_end; loc_ghost = false} in - Location.deprecated loc + deprecated_option ~loc x (Printf.sprintf "Option \"%s\" is deprecated. Use \"%s\" instead." x Literals.esmodule) in @@ -196,10 +199,14 @@ let list_dirs_by (package_specs : t) (f : string -> unit) = type json_map = Ext_json_types.t Map_string.t let extract_js_suffix_exn (map : json_map) : string = + let deprecation = "The \"suffix\" option at the top level is deprecated. Move the \"suffix\" setting into each \"package-specs\" entry." in match map.?(Bsb_build_schemas.suffix) with | None -> Literals.suffix_js - | Some (Str { str = suffix; _ }) when validate_js_suffix suffix -> suffix - | Some ((Str {str; _}) as config) -> + | Some (Str { str = suffix; loc }) when validate_js_suffix suffix -> + deprecated_option ~loc Literals.suffix_js deprecation; + suffix + | Some ((Str {str; loc}) as config) -> + deprecated_option ~loc Literals.suffix_js deprecation; Bsb_exception.config_error config ("invalid suffix \"" ^ str ^ "\". The suffix and may contain letters, digits, \"-\", \"_\" and \".\" and must end with .js, .mjs or .cjs.") | Some config ->