Skip to content

Commit 6de936a

Browse files
authored
Deprecated top-level suffix in the rescript.json (#7056)
* Deprecated top-level suffix in the rescript.json * fix message * changelog
1 parent 0bac05b commit 6de936a

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
- Deprecate JSX 3 https://github.com/rescript-lang/rescript-compiler/pull/7042
1616
- Deprecate js_cast.res https://github.com/rescript-lang/rescript-compiler/pull/7074
17+
- Deprecate top-level `"suffix"` option in `rescript.json`. https://github.com/rescript-lang/rescript-compiler/pull/7056
1718

1819
# 11.1.4
1920

docs/docson/build-schema.json

Lines changed: 2 additions & 8 deletions
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

Lines changed: 14 additions & 7 deletions
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
@@ -196,10 +199,14 @@ let list_dirs_by (package_specs : t) (f : string -> unit) =
196199
type json_map = Ext_json_types.t Map_string.t
197200

198201
let extract_js_suffix_exn (map : json_map) : string =
202+
let deprecation = "The \"suffix\" option at the top level is deprecated. Move the \"suffix\" setting into each \"package-specs\" entry." in
199203
match map.?(Bsb_build_schemas.suffix) with
200204
| None -> Literals.suffix_js
201-
| Some (Str { str = suffix; _ }) when validate_js_suffix suffix -> suffix
202-
| Some ((Str {str; _}) as config) ->
205+
| Some (Str { str = suffix; loc }) when validate_js_suffix suffix ->
206+
deprecated_option ~loc Literals.suffix_js deprecation;
207+
suffix
208+
| Some ((Str {str; loc}) as config) ->
209+
deprecated_option ~loc Literals.suffix_js deprecation;
203210
Bsb_exception.config_error config
204211
("invalid suffix \"" ^ str ^ "\". The suffix and may contain letters, digits, \"-\", \"_\" and \".\" and must end with .js, .mjs or .cjs.")
205212
| Some config ->

0 commit comments

Comments
 (0)