Skip to content

Commit 0e9ed4e

Browse files
authored
Remove JSX v3 (rescript-lang#7072)
* remove jsx v3 * fix genType tests * fix test * changelog * remove syntax test expected * remove v3 from build-schema * remove makeProps from tests
1 parent fdc3e6c commit 0e9ed4e

File tree

89 files changed

+367
-2407
lines changed

Some content is hidden

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

89 files changed

+367
-2407
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#### :boom: Breaking Change
1616

1717
- OCaml compatibility in the stdlib and primitives are dropped/deprecated. https://github.com/rescript-lang/rescript-compiler/pull/6984
18+
- Remove the JSX v3. https://github.com/rescript-lang/rescript-compiler/pull/7072
1819

1920
#### :rocket: New Feature
2021

docs/docson/build-schema.json

+2-19
Original file line numberDiff line numberDiff line change
@@ -304,21 +304,12 @@
304304
},
305305
"description": "path to gentype, path resolution is similar to ReScript"
306306
},
307-
"reason-specs": {
308-
"type": "object",
309-
"properties": {
310-
"react-jsx": {
311-
"$ref": "#/definitions/react-jsx-version",
312-
"description": "Whether to apply the [RescriptReact](https://github.com/rescript-lang/rescript-react)-specific JSX PPX transformation."
313-
}
314-
}
315-
},
316307
"jsx-specs": {
317308
"type": "object",
318309
"properties": {
319310
"version": {
320311
"type": "number",
321-
"enum": [3, 4],
312+
"enum": [4],
322313
"description": "Whether to apply the specific version of JSX PPX transformation"
323314
},
324315
"module": {
@@ -329,10 +320,6 @@
329320
"type": "string",
330321
"enum": ["classic", "automatic"],
331322
"description": "JSX transformation mode"
332-
},
333-
"v3-dependencies": {
334-
"$ref": "#/definitions/dependencies",
335-
"description": "Build the given dependencies in JSX V3 compatibility mode."
336323
}
337324
},
338325
"additionalProperties": false
@@ -422,10 +409,6 @@
422409
"type": "boolean",
423410
"description": "Configuration for the uncurried mode."
424411
},
425-
"reason": {
426-
"$ref": "#/definitions/reason-specs",
427-
"description": "ReScript comes with [Reason](http://reasonml.github.io/) by default. Specific configurations here."
428-
},
429412
"gentypeconfig": {
430413
"$ref": "#/definitions/gentype-specs",
431414
"description": "gentype config, see cristianoc/genType for more details"
@@ -458,7 +441,7 @@
458441
},
459442
"ppx-flags": {
460443
"$ref": "#/definitions/ppx-specs",
461-
"description": "PPX macros to pass to compiler. The syntax is package_name/binary, for example: `reason/reactjs_jsx_ppx_3.native`. Currenly searches in `node_modules`"
444+
"description": "PPX macros to pass to compiler. The syntax is package_name/binary, for example: `rescript-relay/ppx`. Currenly searches in `node_modules`"
462445
},
463446
"pp-flags": {
464447
"$ref": "#/definitions/pp-specs",

jscomp/bsb/bsb_build_schemas.ml

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ let jsx = "jsx"
5252
let jsx_version = "version"
5353
let jsx_module = "module"
5454
let jsx_mode = "mode"
55-
let jsx_v3_dependencies = "v3-dependencies"
5655
let cut_generators = "cut-generators"
5756
let generators = "generators"
5857
let command = "command"

jscomp/bsb/bsb_config_parse.ml

-31
Original file line numberDiff line numberDiff line change
@@ -103,26 +103,6 @@ let extract_boolean (map : json_map) (field : string) (default : bool) : bool =
103103
| Some config ->
104104
Bsb_exception.config_error config (field ^ " expect a boolean")
105105

106-
let extract_reason_react_jsx (map : json_map) =
107-
let default : Bsb_config_types.reason_react_jsx option ref = ref None in
108-
map
109-
|? ( Bsb_build_schemas.reason,
110-
`Obj
111-
(fun m ->
112-
match m.?(Bsb_build_schemas.react_jsx) with
113-
| Some (Flo { loc; flo }) -> (
114-
match flo with
115-
| "3" -> default := Some Jsx_v3
116-
| _ -> Bsb_exception.errorf ~loc "Unsupported jsx version %s" flo
117-
)
118-
| Some x ->
119-
Bsb_exception.config_error x
120-
"Unexpected input (expect a version number) for jsx, note \
121-
boolean is no longer allowed"
122-
| None -> ()) )
123-
|> ignore;
124-
!default
125-
126106
let extract_warning (map : json_map) =
127107
match map.?(Bsb_build_schemas.warnings) with
128108
| None -> Bsb_warning.use_default
@@ -262,7 +242,6 @@ let interpret_json
262242
~desc:Bsb_build_schemas.pp_flags p)
263243
.path)
264244
in
265-
let reason_react_jsx = extract_reason_react_jsx map in
266245
let bs_dependencies =
267246
extract_dependencies map per_proj_dir Bsb_build_schemas.bs_dependencies
268247
in
@@ -287,15 +266,6 @@ let interpret_json
287266
in
288267
let bsc_flags = extract_string_list map Bsb_build_schemas.bsc_flags in
289268
let jsx = Bsb_jsx.from_map map in
290-
let jsx, bsc_flags =
291-
match package_kind with
292-
| Pinned_dependency x | Dependency x ->
293-
if List.mem package_name x.jsx.v3_dependencies then
294-
( { jsx with version = Some Jsx_v3 },
295-
"-open ReactV3" :: bsc_flags )
296-
else (x.jsx, bsc_flags)
297-
| _ -> (jsx, bsc_flags)
298-
in
299269
{
300270
pinned_dependencies;
301271
gentype_config;
@@ -326,7 +296,6 @@ let interpret_json
326296
| Pinned_dependency x | Dependency x -> x.package_specs);
327297
file_groups = groups;
328298
files_to_install = Queue.create ();
329-
reason_react_jsx;
330299
jsx;
331300
generators = extract_generators map;
332301
cut_generators;

jscomp/bsb/bsb_config_types.ml

-3
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ type dependency = {
2828
}
2929

3030
type dependencies = dependency list
31-
type reason_react_jsx = Jsx_v3
32-
(* string option *)
3331

3432
type gentype_config = bool
3533
type command = string
@@ -56,7 +54,6 @@ type t = {
5654
package_specs : Bsb_package_specs.t;
5755
file_groups : Bsb_file_groups.t;
5856
files_to_install : Bsb_db.module_info Queue.t;
59-
reason_react_jsx : reason_react_jsx option;
6057
jsx: Bsb_jsx.t;
6158
(* whether apply PPX transform or not*)
6259
generators : command Map_string.t;

jscomp/bsb/bsb_jsx.ml

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
type version = Jsx_v3 | Jsx_v4
1+
type version = Jsx_v4
22
type module_ = React | Generic of {moduleName: string}
33
type mode = Classic | Automatic
44
type dependencies = string list
@@ -7,13 +7,11 @@ type t = {
77
version : version option;
88
module_ : module_ option;
99
mode : mode option;
10-
v3_dependencies : dependencies;
1110
}
1211

1312
let encode_no_nl jsx =
1413
(match jsx.version with
1514
| None -> ""
16-
| Some Jsx_v3 -> "3"
1715
| Some Jsx_v4 -> "4")
1816
^ (match jsx.module_ with None -> "" | Some React -> "React" | Some Generic {moduleName} -> moduleName)
1917
^
@@ -35,15 +33,13 @@ let from_map map =
3533
let version : version option ref = ref None in
3634
let module_ : module_ option ref = ref None in
3735
let mode : mode option ref = ref None in
38-
let v3_dependencies : dependencies ref = ref [] in
3936
map
4037
|? ( Bsb_build_schemas.jsx,
4138
`Obj
4239
(fun m ->
4340
match m.?(Bsb_build_schemas.jsx_version) with
4441
| Some (Flo { loc; flo }) -> (
4542
match flo with
46-
| "3" -> version := Some Jsx_v3
4743
| "4" -> version := Some Jsx_v4
4844
| _ -> Bsb_exception.errorf ~loc "Unsupported jsx version %s" flo
4945
)
@@ -76,20 +72,9 @@ let from_map map =
7672
Bsb_exception.config_error x
7773
"Unexpected input (expect classic or automatic) for jsx mode"
7874
| None -> ()) )
79-
|? ( Bsb_build_schemas.jsx,
80-
`Obj
81-
(fun m ->
82-
match m.?(Bsb_build_schemas.jsx_v3_dependencies) with
83-
| Some (Arr { content }) ->
84-
v3_dependencies := get_list_string content
85-
| Some x ->
86-
Bsb_exception.config_error x
87-
"Unexpected input for jsx v3-dependencies"
88-
| None -> ()) )
8975
|> ignore;
9076
{
9177
version = !version;
9278
module_ = !module_;
9379
mode = !mode;
94-
v3_dependencies = !v3_dependencies;
9580
}

jscomp/bsb/bsb_ninja_gen.ml

+2-3
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ let output_ninja_and_namespace_map ~per_proj_dir ~package_kind
148148
package_specs;
149149
file_groups = { files = bs_file_groups };
150150
files_to_install;
151-
reason_react_jsx;
152151
jsx;
153152
generators;
154153
namespace;
@@ -195,8 +194,8 @@ let output_ninja_and_namespace_map ~per_proj_dir ~package_kind
195194
in
196195
let rules : Bsb_ninja_rule.builtin =
197196
Bsb_ninja_rule.make_custom_rules ~gentype_config
198-
~has_postbuild:js_post_build_cmd ~pp_file
199-
~reason_react_jsx ~jsx ~package_specs ~namespace ~digest ~package_name
197+
~has_postbuild:js_post_build_cmd ~pp_file ~jsx
198+
~package_specs ~namespace ~digest ~package_name
200199
~warnings ~ppx_files ~bsc_flags ~dpkg_incls (* dev dependencies *)
201200
~lib_incls (* its own libs *)
202201
~dev_incls (* its own devs *)

jscomp/bsb/bsb_ninja_rule.ml

+3-6
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ type builtin = {
8888

8989
let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config)
9090
~(has_postbuild : string option) ~(pp_file : string option)
91-
~(reason_react_jsx : Bsb_config_types.reason_react_jsx option)
9291
~(jsx : Bsb_jsx.t) ~(digest : string) ~(package_specs : Bsb_package_specs.t)
9392
~(namespace : string option) ~package_name ~warnings
9493
~(ppx_files : Bsb_config_types.ppx list) ~bsc_flags ~(dpkg_incls : string)
@@ -156,11 +155,9 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config)
156155
| None -> ()
157156
| Some flag ->
158157
Ext_buffer.add_char_string buf ' ' (Bsb_build_util.pp_flag flag));
159-
(match (reason_react_jsx, jsx.version) with
160-
| _, Some Jsx_v3 -> Ext_buffer.add_string buf " -bs-jsx 3"
161-
| _, Some Jsx_v4 -> Ext_buffer.add_string buf " -bs-jsx 4"
162-
| Some Jsx_v3, None -> Ext_buffer.add_string buf " -bs-jsx 3"
163-
| None, None -> ());
158+
(match (jsx.version) with
159+
| Some Jsx_v4 -> Ext_buffer.add_string buf " -bs-jsx 4"
160+
| None -> ());
164161
(match jsx.module_ with
165162
| None -> ()
166163
| Some React -> Ext_buffer.add_string buf " -bs-jsx-module react"

jscomp/bsb/bsb_ninja_rule.mli

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ val make_custom_rules :
6868
gentype_config:Bsb_config_types.gentype_config ->
6969
has_postbuild:string option ->
7070
pp_file:string option ->
71-
reason_react_jsx:Bsb_config_types.reason_react_jsx option ->
7271
jsx:Bsb_jsx.t ->
7372
digest:string ->
7473
package_specs:Bsb_package_specs.t ->

jscomp/common/js_config.ml

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

2525
(** Browser is not set via command line only for internal use *)
2626

27-
type jsx_version = Jsx_v3 | Jsx_v4
27+
type jsx_version = Jsx_v4
2828
type jsx_module = React | Generic of {module_name: string}
2929
type jsx_mode = Classic | Automatic
3030

@@ -59,7 +59,6 @@ let no_export = ref false
5959
let as_ppx = ref false
6060

6161
let int_of_jsx_version = function
62-
| Jsx_v3 -> 3
6362
| Jsx_v4 -> 4
6463

6564
let string_of_jsx_module = function
@@ -71,7 +70,6 @@ let string_of_jsx_mode = function
7170
| Automatic -> "automatic"
7271

7372
let jsx_version_of_int = function
74-
| 3 -> Some Jsx_v3
7573
| 4 -> Some Jsx_v4
7674
| _ -> None
7775

jscomp/common/js_config.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

25-
type jsx_version = Jsx_v3 | Jsx_v4
25+
type jsx_version = Jsx_v4
2626
type jsx_module = React | Generic of {module_name: string}
2727
type jsx_mode = Classic | Automatic
2828

jscomp/gentype/TranslateTypeExprFromTypes.ml

+5-14
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ let translate_constr ~config ~params_translation ~(path : Path.t) ~type_env =
151151
param_translation1.dependencies @ param_translation2.dependencies;
152152
type_ = variant;
153153
}
154-
| ( (["React"; "callback"] | ["ReactV3"; "React"; "callback"]),
155-
[from_translation; to_translation] ) ->
154+
| ["React"; "callback"], [from_translation; to_translation] ->
156155
{
157156
dependencies = from_translation.dependencies @ to_translation.dependencies;
158157
type_ =
@@ -163,8 +162,7 @@ let translate_constr ~config ~params_translation ~(path : Path.t) ~type_env =
163162
type_vars = [];
164163
};
165164
}
166-
| ( (["React"; "componentLike"] | ["ReactV3"; "React"; "componentLike"]),
167-
[props_translation; ret_translation] ) ->
165+
| ["React"; "componentLike"], [props_translation; ret_translation] ->
168166
{
169167
dependencies =
170168
props_translation.dependencies @ ret_translation.dependencies;
@@ -176,8 +174,7 @@ let translate_constr ~config ~params_translation ~(path : Path.t) ~type_env =
176174
type_vars = [];
177175
};
178176
}
179-
| ( (["React"; "component"] | ["ReactV3"; "React"; "component"]),
180-
[props_translation] ) ->
177+
| ["React"; "component"], [props_translation] ->
181178
{
182179
dependencies = props_translation.dependencies;
183180
type_ =
@@ -188,17 +185,12 @@ let translate_constr ~config ~params_translation ~(path : Path.t) ~type_env =
188185
type_vars = [];
189186
};
190187
}
191-
| ( (["React"; "Context"; "t"] | ["ReactV3"; "React"; "Context"; "t"]),
192-
[param_translation] ) ->
188+
| ["React"; "Context"; "t"], [param_translation] ->
193189
{
194190
dependencies = param_translation.dependencies;
195191
type_ = EmitType.type_react_context ~type_:param_translation.type_;
196192
}
197-
| ( ( ["React"; "Ref"; "t"]
198-
| ["React"; "ref"]
199-
| ["ReactV3"; "React"; "Ref"; "t"]
200-
| ["ReactV3"; "React"; "ref"] ),
201-
[param_translation] ) ->
193+
| (["React"; "Ref"; "t"] | ["React"; "ref"]), [param_translation] ->
202194
{
203195
dependencies = param_translation.dependencies;
204196
type_ = EmitType.type_react_ref ~type_:param_translation.type_;
@@ -214,7 +206,6 @@ let translate_constr ~config ~params_translation ~(path : Path.t) ~type_env =
214206
| ["ReactEvent"; "Mouse"; "t"], [] ->
215207
{dependencies = []; type_ = EmitType.type_react_event_mouse_t}
216208
| ( ( ["React"; "element"]
217-
| ["ReactV3"; "React"; "element"]
218209
| ["ReasonReact"; "reactElement"]
219210
| ["Pervasives"; "Jsx"; "element"] ),
220211
[] ) ->

jscomp/syntax/src/jsx_ppx.ml

+2-14
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ let process_config_attribute attribute config =
7272
if is_jsx_config_attr attribute then update_config config (snd attribute)
7373

7474
let get_mapper ~config =
75-
let ( expr3,
76-
module_binding3,
77-
transform_signature_item3,
78-
transform_structure_item3 ) =
79-
Reactjs_jsx_v3.jsx_mapper ~config
80-
in
8175
let ( expr4,
8276
module_binding4,
8377
transform_signature_item4,
@@ -87,13 +81,11 @@ let get_mapper ~config =
8781

8882
let expr mapper e =
8983
match config.version with
90-
| 3 -> expr3 mapper e
9184
| 4 -> expr4 mapper e
9285
| _ -> default_mapper.expr mapper e
9386
in
9487
let module_binding mapper mb =
9588
match config.version with
96-
| 3 -> module_binding3 mapper mb
9789
| 4 -> module_binding4 mapper mb
9890
| _ -> default_mapper.module_binding mapper mb
9991
in
@@ -122,9 +114,7 @@ let get_mapper ~config =
122114
| Psig_attribute attr -> process_config_attribute attr config
123115
| _ -> ());
124116
let item = default_mapper.signature_item mapper item in
125-
if config.version = 3 then transform_signature_item3 item
126-
else if config.version = 4 then transform_signature_item4 item
127-
else [item])
117+
if config.version = 4 then transform_signature_item4 item else [item])
128118
items
129119
|> List.flatten
130120
in
@@ -141,9 +131,7 @@ let get_mapper ~config =
141131
| Pstr_attribute attr -> process_config_attribute attr config
142132
| _ -> ());
143133
let item = default_mapper.structure_item mapper item in
144-
if config.version = 3 then transform_structure_item3 item
145-
else if config.version = 4 then transform_structure_item4 item
146-
else [item])
134+
if config.version = 4 then transform_structure_item4 item else [item])
147135
items
148136
|> List.flatten
149137
in

0 commit comments

Comments
 (0)