Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated top-level suffix in the rescript.json #7056

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 2 additions & 8 deletions docs/docson/build-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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"]
Expand Down Expand Up @@ -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."
Expand Down
21 changes: 14 additions & 7 deletions jscomp/bsb/bsb_package_specs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ->
Expand Down