Skip to content

Commit 0761aaa

Browse files
committed
Deprecated top-level suffix in the rescript.json
1 parent 5b9d693 commit 0761aaa

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

docs/docson/build-schema.json

+2-8
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
"enum": ["esmodule", "commonjs", "es6", "es6-global"],
66
"description": "es6 and es6-global are deprecated. Default: commonjs."
77
},
8-
"suffix-spec": {
9-
"type": "string",
10-
"description": "Suffix of generated js files. Default: .js. May contain letters, digits, \"-\", \"_\" and \".\" and must end with .js, .mjs or .cjs."
11-
},
128
"module-format-object": {
139
"type": "object",
1410
"properties": {
@@ -20,7 +16,8 @@
2016
"description": "Default: false."
2117
},
2218
"suffix": {
23-
"$ref": "#/definitions/suffix-spec"
19+
"type": "string",
20+
"description": "Suffix of generated js files. Default: .js. May contain letters, digits, \"-\", \"_\" and \".\" and must end with .js, .mjs or .cjs."
2421
}
2522
},
2623
"required": ["module"]
@@ -487,9 +484,6 @@
487484
},
488485
"description": "(Not needed usually) external include directories, which will be applied `-I` to all compilation units"
489486
},
490-
"suffix": {
491-
"$ref": "#/definitions/suffix-spec"
492-
},
493487
"reanalyze": {
494488
"$ref": "#/definitions/reanalyze",
495489
"description": "Configure reanalyze, a static code analysis tool for ReScript."

jscomp/bsb/bsb_package_specs.ml

+17-7
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,17 @@ let bad_module_format_message_exn ~loc format =
4343
of: %s or %s"
4444
format Literals.esmodule Literals.commonjs
4545

46+
let deprecated_option ~loc x message =
47+
let loc_end =
48+
{loc with Lexing.pos_cnum = loc.Lexing.pos_cnum + String.length x}
49+
in
50+
let loc = {Warnings.loc_start = loc; loc_end; loc_ghost = false} in
51+
Location.deprecated loc message
52+
4653
let supported_format (x : string) loc : Ext_module_system.t =
4754
let _ =
4855
if x = Literals.es6 || x = Literals.es6_global then
49-
let loc_end =
50-
{loc with Lexing.pos_cnum = loc.Lexing.pos_cnum + String.length x}
51-
in
52-
let loc = {Warnings.loc_start = loc; loc_end; loc_ghost = false} in
53-
Location.deprecated loc
56+
deprecated_option ~loc x
5457
(Printf.sprintf "Option \"%s\" is deprecated. Use \"%s\" instead." x
5558
Literals.esmodule)
5659
in
@@ -198,8 +201,15 @@ type json_map = Ext_json_types.t Map_string.t
198201
let extract_js_suffix_exn (map : json_map) : string =
199202
match map.?(Bsb_build_schemas.suffix) with
200203
| None -> Literals.suffix_js
201-
| Some (Str { str = suffix; _ }) when validate_js_suffix suffix -> suffix
202-
| Some ((Str {str; _}) as config) ->
204+
| Some (Str { str = suffix; loc }) when validate_js_suffix suffix ->
205+
deprecated_option ~loc
206+
Literals.suffix_js
207+
(Printf.sprintf "Top-level suffix is deprecated. Move it into each package-specs.");
208+
suffix
209+
| Some ((Str {str; loc}) as config) ->
210+
deprecated_option ~loc
211+
Literals.suffix_js
212+
(Printf.sprintf "Top-level suffix is deprecated. Move it into each package-specs.");
203213
Bsb_exception.config_error config
204214
("invalid suffix \"" ^ str ^ "\". The suffix and may contain letters, digits, \"-\", \"_\" and \".\" and must end with .js, .mjs or .cjs.")
205215
| Some config ->

0 commit comments

Comments
 (0)