Skip to content

Commit dfd941e

Browse files
authored
Remove jsx mode (#7327)
* Remove jsx-mode * Update bsb and run tests * Remove jsx-mode from tests * Remove old expected files * Remove redundant optional argument * Remove mode in playground * Remove JsxPPXReactSupport from artifacts.txt * Restore -bs-jsx-mode * Format
1 parent 2716c0c commit dfd941e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+182
-1496
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#### :boom: Breaking Change
2323

2424
- Replace ~date with ~day in Date.make\*. https://github.com/rescript-lang/rescript/pull/7324
25+
- Remove `-bs-jsx-mode`. https://github.com/rescript-lang/rescript/pull/7327
2526

2627
#### :house: Internal
2728

compiler/bsb/bsb_build_schemas.ml

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ let react_jsx = "react-jsx"
5151
let jsx = "jsx"
5252
let jsx_version = "version"
5353
let jsx_module = "module"
54-
let jsx_mode = "mode"
5554
let cut_generators = "cut-generators"
5655
let generators = "generators"
5756
let command = "command"

compiler/bsb/bsb_jsx.ml

+5-24
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
type version = Jsx_v4
22
type module_ = React | Generic of {moduleName: string}
3-
type mode = Classic | Automatic
43
type dependencies = string list
54

6-
type t = {version: version option; module_: module_ option; mode: mode option}
5+
type t = {version: version option; module_: module_ option}
76

87
let encode_no_nl jsx =
98
(match jsx.version with
109
| None -> ""
1110
| Some Jsx_v4 -> "4")
12-
^ (match jsx.module_ with
13-
| None -> ""
14-
| Some React -> "React"
15-
| Some (Generic {moduleName}) -> moduleName)
1611
^
17-
match jsx.mode with
12+
match jsx.module_ with
1813
| None -> ""
19-
| Some Classic -> "Classic"
20-
| Some Automatic -> "Automatic"
14+
| Some React -> "React"
15+
| Some (Generic {moduleName}) -> moduleName
2116

2217
let ( .?() ) = Map_string.find_opt
2318
let ( |? ) m (key, cb) = m |> Ext_json.test key cb
@@ -33,7 +28,6 @@ let get_list_string s = get_list_string_acc s []
3328
let from_map map =
3429
let version : version option ref = ref None in
3530
let module_ : module_ option ref = ref None in
36-
let mode : mode option ref = ref None in
3731
map
3832
|? ( Bsb_build_schemas.jsx,
3933
`Obj
@@ -59,18 +53,5 @@ let from_map map =
5953
Bsb_exception.config_error x
6054
"Unexpected input (jsx module name) for jsx module"
6155
| None -> ()) )
62-
|? ( Bsb_build_schemas.jsx,
63-
`Obj
64-
(fun m ->
65-
match m.?(Bsb_build_schemas.jsx_mode) with
66-
| Some (Str {loc; str}) -> (
67-
match str with
68-
| "classic" -> mode := Some Classic
69-
| "automatic" -> mode := Some Automatic
70-
| _ -> Bsb_exception.errorf ~loc "Unsupported jsx mode %s" str)
71-
| Some x ->
72-
Bsb_exception.config_error x
73-
"Unexpected input (expect classic or automatic) for jsx mode"
74-
| None -> ()) )
7556
|> ignore;
76-
{version = !version; module_ = !module_; mode = !mode}
57+
{version = !version; module_ = !module_}

compiler/bsb/bsb_ninja_rule.ml

-4
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,6 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config)
167167
| Some React -> Ext_buffer.add_string buf " -bs-jsx-module react"
168168
| Some (Generic {moduleName}) ->
169169
Ext_buffer.add_string buf (" -bs-jsx-module " ^ moduleName));
170-
(match jsx.mode with
171-
| None -> ()
172-
| Some Classic -> Ext_buffer.add_string buf " -bs-jsx-mode classic"
173-
| Some Automatic -> Ext_buffer.add_string buf " -bs-jsx-mode automatic");
174170

175171
Ext_buffer.add_char_string buf ' ' bsc_flags;
176172
Ext_buffer.add_string buf " -absname -bs-ast -o $out $i";

compiler/bsc/rescript_compiler_main.ml

+3-8
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,11 @@ let buckle_script_flags : (string * Bsc_args.spec * string) array =
254254
| _ -> true
255255
in
256256
Js_config.jsx_module := Js_config.jsx_module_of_string i;
257-
if is_generic then (
258-
Js_config.jsx_mode := Automatic;
259-
Js_config.jsx_version := Some Jsx_v4)),
257+
if is_generic then Js_config.jsx_version := Some Jsx_v4),
260258
"*internal* Set jsx module" );
261259
( "-bs-jsx-mode",
262-
string_call (fun i ->
263-
if i <> "classic" && i <> "automatic" then
264-
Bsc_args.bad_arg (" Not supported jsx-mode : " ^ i);
265-
Js_config.jsx_mode := Js_config.jsx_mode_of_string i),
266-
"*internal* Set jsx mode" );
260+
string_call ignore,
261+
"*internal* Set jsx mode, this is no longer used and is a no-op." );
267262
( "-bs-package-output",
268263
string_call Js_packages_state.update_npm_package_path,
269264
"*internal* Set npm-output-path: [opt_module]:path, for example: \

compiler/common/js_config.ml

-11
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
type jsx_version = Jsx_v4
2828
type jsx_module = React | Generic of {module_name: string}
29-
type jsx_mode = Classic | Automatic
3029

3130
let no_version_header = ref false
3231

@@ -51,7 +50,6 @@ let force_cmi = ref false
5150
let force_cmj = ref false
5251
let jsx_version = ref None
5352
let jsx_module = ref React
54-
let jsx_mode = ref Automatic
5553
let js_stdout = ref true
5654
let all_module_aliases = ref false
5755
let no_stdlib = ref false
@@ -63,10 +61,6 @@ let string_of_jsx_module = function
6361
| React -> "react"
6462
| Generic {module_name} -> module_name
6563

66-
let string_of_jsx_mode = function
67-
| Classic -> "classic"
68-
| Automatic -> "automatic"
69-
7064
let jsx_version_of_int = function
7165
| 4 -> Some Jsx_v4
7266
| _ -> None
@@ -75,11 +69,6 @@ let jsx_module_of_string = function
7569
| "react" -> React
7670
| module_name -> Generic {module_name}
7771

78-
let jsx_mode_of_string = function
79-
| "classic" -> Classic
80-
| "automatic" -> Automatic
81-
| _ -> Classic
82-
8372
(* option to config `@rescript/std`*)
8473
let customize_runtime : string option ref = ref None
8574
let as_pp = ref false

compiler/common/js_config.mli

-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
type jsx_version = Jsx_v4
2626
type jsx_module = React | Generic of {module_name: string}
27-
type jsx_mode = Classic | Automatic
2827

2928
(* val get_packages_info :
3029
unit -> Js_packages_info.t *)
@@ -81,8 +80,6 @@ val jsx_version : jsx_version option ref
8180

8281
val jsx_module : jsx_module ref
8382

84-
val jsx_mode : jsx_mode ref
85-
8683
val js_stdout : bool ref
8784

8885
val all_module_aliases : bool ref
@@ -95,14 +92,10 @@ val int_of_jsx_version : jsx_version -> int
9592

9693
val string_of_jsx_module : jsx_module -> string
9794

98-
val string_of_jsx_mode : jsx_mode -> string
99-
10095
val jsx_version_of_int : int -> jsx_version option
10196

10297
val jsx_module_of_string : string -> jsx_module
10398

104-
val jsx_mode_of_string : string -> jsx_mode
105-
10699
val customize_runtime : string option ref
107100

108101
val as_pp : bool ref

compiler/frontend/ppx_entry.ml

+2-4
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ let rewrite_signature (ast : Parsetree.signature) : Parsetree.signature =
3434
let open Js_config in
3535
let jsx_version = int_of_jsx_version jsx_version_ in
3636
let jsx_module = string_of_jsx_module !jsx_module in
37-
let jsx_mode = string_of_jsx_mode !jsx_mode in
38-
Jsx_ppx.rewrite_signature ~jsx_version ~jsx_module ~jsx_mode ast
37+
Jsx_ppx.rewrite_signature ~jsx_version ~jsx_module ast
3938
in
4039
if !Js_config.no_builtin_ppx then ast
4140
else
@@ -54,8 +53,7 @@ let rewrite_implementation (ast : Parsetree.structure) : Parsetree.structure =
5453
let open Js_config in
5554
let jsx_version = int_of_jsx_version jsx_version_ in
5655
let jsx_module = string_of_jsx_module !jsx_module in
57-
let jsx_mode = string_of_jsx_mode !jsx_mode in
58-
Jsx_ppx.rewrite_implementation ~jsx_version ~jsx_module ~jsx_mode ast
56+
Jsx_ppx.rewrite_implementation ~jsx_version ~jsx_module ast
5957
in
6058
if !Js_config.no_builtin_ppx then ast
6159
else

compiler/jsoo/jsoo_playground_main.ml

-2
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,6 @@ module Compile = struct
488488
let types_signature = ref [] in
489489
Js_config.jsx_version := Some Js_config.Jsx_v4;
490490
(* default *)
491-
Js_config.jsx_mode := Js_config.Automatic;
492-
(* default *)
493491
let ast = impl str in
494492
let ast = Ppx_entry.rewrite_implementation ast in
495493
let typed_tree =

compiler/syntax/cli/res_cli.ml

+5-11
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ module ResClflags : sig
163163
val interface : bool ref
164164
val jsx_version : int ref
165165
val jsx_module : string ref
166-
val jsx_mode : string ref
167166
val typechecker : bool ref
168167
val test_ast_conversion : bool ref
169168

@@ -176,7 +175,6 @@ end = struct
176175
let interface = ref false
177176
let jsx_version = ref (-1)
178177
let jsx_module = ref "react"
179-
let jsx_mode = ref "automatic"
180178
let file = ref ""
181179
let typechecker = ref false
182180
let test_ast_conversion = ref false
@@ -210,9 +208,6 @@ end = struct
210208
( "-jsx-module",
211209
Arg.String (fun txt -> jsx_module := txt),
212210
"Specify the jsx module. Default: react" );
213-
( "-jsx-mode",
214-
Arg.String (fun txt -> jsx_mode := txt),
215-
"Specify the jsx mode, classic or automatic. Default: automatic" );
216211
( "-typechecker",
217212
Arg.Unit (fun () -> typechecker := true),
218213
"Parses the ast as it would be passed to the typechecker and not the \
@@ -230,7 +225,7 @@ module CliArgProcessor = struct
230225
[@@unboxed]
231226

232227
let process_file ~is_interface ~width ~recover ~target ~jsx_version
233-
~jsx_module ~jsx_mode ~typechecker ~test_ast_conversion filename =
228+
~jsx_module ~typechecker ~test_ast_conversion filename =
234229
let len = String.length filename in
235230
let process_interface =
236231
is_interface
@@ -282,7 +277,7 @@ module CliArgProcessor = struct
282277
Ast_mapper_from0.default_mapper tree0
283278
in
284279
let parsetree =
285-
Jsx_ppx.rewrite_signature ~jsx_version ~jsx_module ~jsx_mode parsetree
280+
Jsx_ppx.rewrite_signature ~jsx_version ~jsx_module parsetree
286281
in
287282
print_engine.print_interface ~width ~filename
288283
~comments:parse_result.comments parsetree
@@ -307,8 +302,7 @@ module CliArgProcessor = struct
307302
Ast_mapper_from0.default_mapper tree0
308303
in
309304
let parsetree =
310-
Jsx_ppx.rewrite_implementation ~jsx_version ~jsx_module ~jsx_mode
311-
parsetree
305+
Jsx_ppx.rewrite_implementation ~jsx_version ~jsx_module parsetree
312306
in
313307
print_engine.print_implementation ~width ~filename
314308
~comments:parse_result.comments parsetree
@@ -321,7 +315,7 @@ let () =
321315
CliArgProcessor.process_file ~is_interface:!ResClflags.interface
322316
~width:!ResClflags.width ~recover:!ResClflags.recover
323317
~target:!ResClflags.print ~jsx_version:!ResClflags.jsx_version
324-
~jsx_module:!ResClflags.jsx_module ~jsx_mode:!ResClflags.jsx_mode
325-
~typechecker:!ResClflags.typechecker !ResClflags.file
318+
~jsx_module:!ResClflags.jsx_module ~typechecker:!ResClflags.typechecker
319+
!ResClflags.file
326320
~test_ast_conversion:!ResClflags.test_ast_conversion)
327321
[@@raises exit]

compiler/syntax/src/jsx_common.ml

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ open Parsetree
44
type jsx_config = {
55
mutable version: int;
66
mutable module_: string;
7-
mutable mode: string;
87
mutable nested_modules: string list;
98
mutable has_component: bool;
109
}

compiler/syntax/src/jsx_ppx.ml

+6-14
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,9 @@ let update_config config payload =
5858
| true, _ -> config.Jsx_common.version <- 4
5959
| false, Some i -> config.Jsx_common.version <- i
6060
| _ -> ());
61-
(match module_raw with
61+
match module_raw with
6262
| None -> ()
63-
| Some s -> config.module_ <- s);
64-
match (is_generic, get_string ~key:"mode" fields) with
65-
| true, _ -> config.mode <- "automatic"
66-
| false, Some s -> config.mode <- s
67-
| _ -> ()
63+
| Some s -> config.module_ <- s
6864

6965
let is_jsx_config_attr ((loc, _) : attribute) = loc.txt = "jsxConfig"
7066

@@ -94,14 +90,12 @@ let get_mapper ~config =
9490
config with
9591
version = config.version;
9692
module_ = config.module_;
97-
mode = config.mode;
9893
has_component = config.has_component;
9994
}
10095
in
10196
let restore_config old_config =
10297
config.version <- old_config.Jsx_common.version;
10398
config.module_ <- old_config.module_;
104-
config.mode <- old_config.mode;
10599
config.has_component <- old_config.has_component
106100
in
107101
let signature mapper items =
@@ -141,27 +135,25 @@ let get_mapper ~config =
141135

142136
{default_mapper with expr; module_binding; signature; structure}
143137

144-
let rewrite_implementation ~jsx_version ~jsx_module ~jsx_mode
145-
(code : Parsetree.structure) : Parsetree.structure =
138+
let rewrite_implementation ~jsx_version ~jsx_module (code : Parsetree.structure)
139+
: Parsetree.structure =
146140
let config =
147141
{
148142
Jsx_common.version = jsx_version;
149143
module_ = jsx_module;
150-
mode = jsx_mode;
151144
nested_modules = [];
152145
has_component = false;
153146
}
154147
in
155148
let mapper = get_mapper ~config in
156149
mapper.structure mapper code
157150

158-
let rewrite_signature ~jsx_version ~jsx_module ~jsx_mode
159-
(code : Parsetree.signature) : Parsetree.signature =
151+
let rewrite_signature ~jsx_version ~jsx_module (code : Parsetree.signature) :
152+
Parsetree.signature =
160153
let config =
161154
{
162155
Jsx_common.version = jsx_version;
163156
module_ = jsx_module;
164-
mode = jsx_mode;
165157
nested_modules = [];
166158
has_component = false;
167159
}

compiler/syntax/src/jsx_ppx.mli

-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@
1111
val rewrite_implementation :
1212
jsx_version:int ->
1313
jsx_module:string ->
14-
jsx_mode:string ->
1514
Parsetree.structure ->
1615
Parsetree.structure
1716

1817
val rewrite_signature :
1918
jsx_version:int ->
2019
jsx_module:string ->
21-
jsx_mode:string ->
2220
Parsetree.signature ->
2321
Parsetree.signature

0 commit comments

Comments
 (0)