Skip to content

Commit 561f809

Browse files
committed
Remove jsx-mode
1 parent 8f8b2f9 commit 561f809

File tree

10 files changed

+126
-341
lines changed

10 files changed

+126
-341
lines changed

compiler/bsc/rescript_compiler_main.ml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,8 @@ 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" );
261-
( "-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" );
267259
( "-bs-package-output",
268260
string_call Js_packages_state.update_npm_package_path,
269261
"*internal* Set npm-output-path: [opt_module]:path, for example: \

compiler/common/js_config.ml

Lines changed: 0 additions & 11 deletions
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

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

Lines changed: 2 additions & 4 deletions
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/syntax/cli/res_cli.ml

Lines changed: 5 additions & 11 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 6 additions & 14 deletions
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

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