Skip to content

Commit 2d90377

Browse files
committed
clean up unused pattern, sync jsx ppx interface
1 parent e0a2be4 commit 2d90377

9 files changed

+8016
-7611
lines changed

jscomp/bsb/bsb_ninja_rule.ml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config)
145145
Ext_buffer.add_string buf " $out_last");
146146
Ext_buffer.contents buf
147147
in
148-
let mk_ast ~has_reason_react_jsx : string =
148+
let mk_ast =
149149
Ext_buffer.clear buf;
150150
Ext_buffer.add_string buf bsc;
151151
Ext_buffer.add_char_string buf ' ' warnings;
@@ -163,11 +163,11 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config)
163163
| None -> ()
164164
| Some flag ->
165165
Ext_buffer.add_char_string buf ' ' (Bsb_build_util.pp_flag flag));
166-
(match (has_reason_react_jsx, reason_react_jsx, jsx_version) with
167-
| _, _, Some Jsx_v3 -> Ext_buffer.add_string buf " -bs-jsx 3"
168-
| _, _, Some Jsx_v4 -> Ext_buffer.add_string buf " -bs-jsx 4"
169-
| _, Some Jsx_v3, None -> Ext_buffer.add_string buf " -bs-jsx 3"
170-
| _ -> ());
166+
(match (reason_react_jsx, jsx_version) with
167+
| _, Some Jsx_v3 -> Ext_buffer.add_string buf " -bs-jsx 3"
168+
| _, Some Jsx_v4 -> Ext_buffer.add_string buf " -bs-jsx 4"
169+
| Some Jsx_v3, None -> Ext_buffer.add_string buf " -bs-jsx 3"
170+
| None, None -> ());
171171
(match jsx_module with
172172
| None -> ()
173173
| Some React -> Ext_buffer.add_string buf " -bs-jsx-module react");
@@ -180,10 +180,8 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config)
180180
Ext_buffer.add_string buf " -absname -bs-ast -o $out $i";
181181
Ext_buffer.contents buf
182182
in
183-
let build_ast = define ~command:(mk_ast ~has_reason_react_jsx:false) "ast" in
184-
let build_ast_from_re =
185-
define ~command:(mk_ast ~has_reason_react_jsx:true) "astj"
186-
in
183+
let build_ast = define ~command:mk_ast "ast" in
184+
let build_ast_from_re = define ~command:mk_ast "astj" in
187185

188186
let copy_resources =
189187
define

jscomp/frontend/ppx_entry.ml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@ let rewrite_signature (ast : Parsetree.signature) : Parsetree.signature =
2828
Bs_ast_invariant.iter_warnings_on_sigi ast;
2929
Ast_config.iter_on_bs_config_sigi ast;
3030
let ast =
31-
match !Js_config.jsx_version with
32-
| 3 -> Reactjs_jsx_ppx_v3.rewrite_signature ast
33-
| 4 -> Reactjs_jsx_ppx_v4.rewrite_signature !Js_config.jsx_mode ast
34-
| _ -> ast
35-
(* react-jsx ppx relies on built-in ones like `##` *)
31+
Reactjs_jsx_ppx.rewrite_signature ~jsxVersion:!Js_config.jsx_version
32+
~jsxModule:!Js_config.jsx_module ~jsxMode:!Js_config.jsx_mode ast
3633
in
3734
if !Js_config.no_builtin_ppx then ast
3835
else
@@ -45,10 +42,8 @@ let rewrite_implementation (ast : Parsetree.structure) : Parsetree.structure =
4542
Bs_ast_invariant.iter_warnings_on_stru ast;
4643
Ast_config.iter_on_bs_config_stru ast;
4744
let ast =
48-
match !Js_config.jsx_version with
49-
| 3 -> Reactjs_jsx_ppx_v3.rewrite_implementation ast
50-
| 4 -> Reactjs_jsx_ppx_v4.rewrite_implementation !Js_config.jsx_mode ast
51-
| _ -> ast
45+
Reactjs_jsx_ppx.rewrite_implementation ~jsxVersion:!Js_config.jsx_version
46+
~jsxModule:!Js_config.jsx_module ~jsxMode:!Js_config.jsx_mode ast
5247
in
5348
if !Js_config.no_builtin_ppx then ast
5449
else

lib/4.06.1/rescript.ml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11748,7 +11748,7 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config)
1174811748
Ext_buffer.add_string buf " $out_last");
1174911749
Ext_buffer.contents buf
1175011750
in
11751-
let mk_ast ~has_reason_react_jsx : string =
11751+
let mk_ast =
1175211752
Ext_buffer.clear buf;
1175311753
Ext_buffer.add_string buf bsc;
1175411754
Ext_buffer.add_char_string buf ' ' warnings;
@@ -11766,11 +11766,11 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config)
1176611766
| None -> ()
1176711767
| Some flag ->
1176811768
Ext_buffer.add_char_string buf ' ' (Bsb_build_util.pp_flag flag));
11769-
(match (has_reason_react_jsx, reason_react_jsx, jsx_version) with
11770-
| _, _, Some Jsx_v3 -> Ext_buffer.add_string buf " -bs-jsx 3"
11771-
| _, _, Some Jsx_v4 -> Ext_buffer.add_string buf " -bs-jsx 4"
11772-
| _, Some Jsx_v3, None -> Ext_buffer.add_string buf " -bs-jsx 3"
11773-
| _ -> ());
11769+
(match (reason_react_jsx, jsx_version) with
11770+
| _, Some Jsx_v3 -> Ext_buffer.add_string buf " -bs-jsx 3"
11771+
| _, Some Jsx_v4 -> Ext_buffer.add_string buf " -bs-jsx 4"
11772+
| Some Jsx_v3, None -> Ext_buffer.add_string buf " -bs-jsx 3"
11773+
| None, None -> ());
1177411774
(match jsx_module with
1177511775
| None -> ()
1177611776
| Some React -> Ext_buffer.add_string buf " -bs-jsx-module react");
@@ -11783,10 +11783,8 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config)
1178311783
Ext_buffer.add_string buf " -absname -bs-ast -o $out $i";
1178411784
Ext_buffer.contents buf
1178511785
in
11786-
let build_ast = define ~command:(mk_ast ~has_reason_react_jsx:false) "ast" in
11787-
let build_ast_from_re =
11788-
define ~command:(mk_ast ~has_reason_react_jsx:true) "astj"
11789-
in
11786+
let build_ast = define ~command:mk_ast "ast" in
11787+
let build_ast_from_re = define ~command:mk_ast "astj" in
1179011788

1179111789
let copy_resources =
1179211790
define

0 commit comments

Comments
 (0)