Skip to content

Commit 0e9ed4e

Browse files
authored
Remove JSX v3 (#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

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

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

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

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

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

Lines changed: 1 addition & 16 deletions
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

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

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

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

Lines changed: 1 addition & 3 deletions
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

0 commit comments

Comments
 (0)