Skip to content

Commit 5a399fa

Browse files
committed
Add jsx config for V3 compatibility mode.
1 parent 427fb8a commit 5a399fa

File tree

5 files changed

+42
-30
lines changed

5 files changed

+42
-30
lines changed

docs/docson/build-schema.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,9 @@
346346
"enum": ["classic", "automatic"],
347347
"description": "JSX transformation mode"
348348
},
349-
"preserve-dependencies": {
349+
"v3-dependencies": {
350350
"$ref": "#/definitions/dependencies",
351-
"description": "Don't propagate the jsx configuration to these dependencies."
351+
"description": "Build the given dependencies in JSX V3 compatibility mode."
352352
}
353353
},
354354
"additionalProperties": false,

jscomp/bsb/bsb_build_schemas.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ let jsx = "jsx"
6262
let jsx_version = "version"
6363
let jsx_module = "module"
6464
let jsx_mode = "mode"
65-
let jsx_preserve_dependencies = "preserve-dependencies"
65+
let jsx_v3_dependencies = "v3-dependencies"
6666
let entries = "entries"
6767
let backend = "backend"
6868
let main_module = "main-module"

jscomp/bsb/bsb_config_parse.ml

+13-7
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,17 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string)
298298
(* ~namespace *)
299299
sources
300300
in
301+
let jsx, bsc_flags =
302+
match package_kind with
303+
| (Pinned_dependency x | Dependency x)
304+
when List.mem package_name x.jsx.v3_dependencies ->
305+
( { (Bsb_jsx.from_map map) with version = Some Jsx_v3 },
306+
"-open ReactV3"
307+
:: extract_string_list map Bsb_build_schemas.bsc_flags )
308+
| _ ->
309+
( Bsb_jsx.from_map map,
310+
extract_string_list map Bsb_build_schemas.bsc_flags )
311+
in
301312
{
302313
pinned_dependencies;
303314
gentype_config;
@@ -306,7 +317,7 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string)
306317
warning = extract_warning map;
307318
external_includes =
308319
extract_string_list map Bsb_build_schemas.bs_external_includes;
309-
bsc_flags = extract_string_list map Bsb_build_schemas.bsc_flags;
320+
bsc_flags;
310321
ppx_files =
311322
extract_ppx map ~cwd:per_proj_dir Bsb_build_schemas.ppx_flags;
312323
pp_file = pp_flags;
@@ -332,12 +343,7 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string)
332343
generate_merlin =
333344
extract_boolean map Bsb_build_schemas.generate_merlin false;
334345
reason_react_jsx;
335-
jsx =
336-
(match package_kind with
337-
| (Pinned_dependency x | Dependency x)
338-
when not (List.mem package_name x.jsx.preserve_dependencies) ->
339-
x.jsx
340-
| _ -> Bsb_jsx.from_map map);
346+
jsx;
341347
generators = extract_generators map;
342348
cut_generators;
343349
}

jscomp/bsb/bsb_jsx.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type t = {
77
version : version option;
88
module_ : module_ option;
99
mode : mode option;
10-
preserve_dependencies : dependencies;
10+
v3_dependencies : dependencies;
1111
}
1212

1313
let encode_no_nl jsx =
@@ -35,7 +35,7 @@ let from_map map =
3535
let version : version option ref = ref None in
3636
let module_ : module_ option ref = ref None in
3737
let mode : mode option ref = ref None in
38-
let preserve_dependencies : dependencies ref = ref [] in
38+
let v3_dependencies : dependencies ref = ref [] in
3939
map
4040
|? ( Bsb_build_schemas.jsx,
4141
`Obj
@@ -79,17 +79,17 @@ let from_map map =
7979
|? ( Bsb_build_schemas.jsx,
8080
`Obj
8181
(fun m ->
82-
match m.?(Bsb_build_schemas.jsx_preserve_dependencies) with
82+
match m.?(Bsb_build_schemas.jsx_v3_dependencies) with
8383
| Some (Arr { content }) ->
84-
preserve_dependencies := get_list_string content
84+
v3_dependencies := get_list_string content
8585
| Some x ->
8686
Bsb_exception.config_error x
87-
"Unexpected input for jsx preserve-dependencies"
87+
"Unexpected input for jsx v3-dependencies"
8888
| None -> ()) )
8989
|> ignore;
9090
{
9191
version = !version;
9292
module_ = !module_;
9393
mode = !mode;
94-
preserve_dependencies = !preserve_dependencies;
94+
v3_dependencies = !v3_dependencies;
9595
}

lib/4.06.1/rescript.ml

+20-14
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ let jsx = "jsx"
17481748
let jsx_version = "version"
17491749
let jsx_module = "module"
17501750
let jsx_mode = "mode"
1751-
let jsx_preserve_dependencies = "preserve-dependencies"
1751+
let jsx_v3_dependencies = "v3-dependencies"
17521752
let entries = "entries"
17531753
let backend = "backend"
17541754
let main_module = "main-module"
@@ -5128,7 +5128,7 @@ type t = {
51285128
version : version option;
51295129
module_ : module_ option;
51305130
mode : mode option;
5131-
preserve_dependencies : dependencies;
5131+
v3_dependencies : dependencies;
51325132
}
51335133

51345134
let encode_no_nl jsx =
@@ -5156,7 +5156,7 @@ let from_map map =
51565156
let version : version option ref = ref None in
51575157
let module_ : module_ option ref = ref None in
51585158
let mode : mode option ref = ref None in
5159-
let preserve_dependencies : dependencies ref = ref [] in
5159+
let v3_dependencies : dependencies ref = ref [] in
51605160
map
51615161
|? ( Bsb_build_schemas.jsx,
51625162
`Obj
@@ -5200,19 +5200,19 @@ let from_map map =
52005200
|? ( Bsb_build_schemas.jsx,
52015201
`Obj
52025202
(fun m ->
5203-
match m.?(Bsb_build_schemas.jsx_preserve_dependencies) with
5203+
match m.?(Bsb_build_schemas.jsx_v3_dependencies) with
52045204
| Some (Arr { content }) ->
5205-
preserve_dependencies := get_list_string content
5205+
v3_dependencies := get_list_string content
52065206
| Some x ->
52075207
Bsb_exception.config_error x
5208-
"Unexpected input for jsx preserve-dependencies"
5208+
"Unexpected input for jsx v3-dependencies"
52095209
| None -> ()) )
52105210
|> ignore;
52115211
{
52125212
version = !version;
52135213
module_ = !module_;
52145214
mode = !mode;
5215-
preserve_dependencies = !preserve_dependencies;
5215+
v3_dependencies = !v3_dependencies;
52165216
}
52175217

52185218
end
@@ -10593,6 +10593,17 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string)
1059310593
(* ~namespace *)
1059410594
sources
1059510595
in
10596+
let jsx, bsc_flags =
10597+
match package_kind with
10598+
| (Pinned_dependency x | Dependency x)
10599+
when List.mem package_name x.jsx.v3_dependencies ->
10600+
( { (Bsb_jsx.from_map map) with version = Some Jsx_v3 },
10601+
"-open ReactV3"
10602+
:: extract_string_list map Bsb_build_schemas.bsc_flags )
10603+
| _ ->
10604+
( Bsb_jsx.from_map map,
10605+
extract_string_list map Bsb_build_schemas.bsc_flags )
10606+
in
1059610607
{
1059710608
pinned_dependencies;
1059810609
gentype_config;
@@ -10601,7 +10612,7 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string)
1060110612
warning = extract_warning map;
1060210613
external_includes =
1060310614
extract_string_list map Bsb_build_schemas.bs_external_includes;
10604-
bsc_flags = extract_string_list map Bsb_build_schemas.bsc_flags;
10615+
bsc_flags;
1060510616
ppx_files =
1060610617
extract_ppx map ~cwd:per_proj_dir Bsb_build_schemas.ppx_flags;
1060710618
pp_file = pp_flags;
@@ -10627,12 +10638,7 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string)
1062710638
generate_merlin =
1062810639
extract_boolean map Bsb_build_schemas.generate_merlin false;
1062910640
reason_react_jsx;
10630-
jsx =
10631-
(match package_kind with
10632-
| (Pinned_dependency x | Dependency x)
10633-
when not (List.mem package_name x.jsx.preserve_dependencies) ->
10634-
x.jsx
10635-
| _ -> Bsb_jsx.from_map map);
10641+
jsx;
1063610642
generators = extract_generators map;
1063710643
cut_generators;
1063810644
}

0 commit comments

Comments
 (0)