Skip to content

Commit e77774f

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

File tree

9 files changed

+8017
-7612
lines changed

9 files changed

+8017
-7612
lines changed

jscomp/bsb/bsb_ninja_rule.ml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config option)
146146
Ext_buffer.add_string buf " $out_last");
147147
Ext_buffer.contents buf
148148
in
149-
let mk_ast ~has_reason_react_jsx : string =
149+
let mk_ast =
150150
Ext_buffer.clear buf;
151151
Ext_buffer.add_string buf bsc;
152152
Ext_buffer.add_char_string buf ' ' warnings;
@@ -164,11 +164,11 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config option)
164164
| None -> ()
165165
| Some flag ->
166166
Ext_buffer.add_char_string buf ' ' (Bsb_build_util.pp_flag flag));
167-
(match (has_reason_react_jsx, reason_react_jsx, jsx_version) with
168-
| _, _, Some Jsx_v3 -> Ext_buffer.add_string buf " -bs-jsx 3"
169-
| _, _, Some Jsx_v4 -> Ext_buffer.add_string buf " -bs-jsx 4"
170-
| _, Some Jsx_v3, None -> Ext_buffer.add_string buf " -bs-jsx 3"
171-
| _ -> ());
167+
(match (reason_react_jsx, jsx_version) with
168+
| _, Some Jsx_v3 -> Ext_buffer.add_string buf " -bs-jsx 3"
169+
| _, Some Jsx_v4 -> Ext_buffer.add_string buf " -bs-jsx 4"
170+
| Some Jsx_v3, None -> Ext_buffer.add_string buf " -bs-jsx 3"
171+
| None, None -> ());
172172
(match jsx_module with
173173
| None -> ()
174174
| Some React -> Ext_buffer.add_string buf " -bs-jsx-module react");
@@ -181,10 +181,8 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config option)
181181
Ext_buffer.add_string buf " -absname -bs-ast -o $out $i";
182182
Ext_buffer.contents buf
183183
in
184-
let build_ast = define ~command:(mk_ast ~has_reason_react_jsx:false) "ast" in
185-
let build_ast_from_re =
186-
define ~command:(mk_ast ~has_reason_react_jsx:true) "astj"
187-
in
184+
let build_ast = define ~command:mk_ast "ast" in
185+
let build_ast_from_re = define ~command:mk_ast "astj" in
188186

189187
let copy_resources =
190188
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
@@ -11764,7 +11764,7 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config option)
1176411764
Ext_buffer.add_string buf " $out_last");
1176511765
Ext_buffer.contents buf
1176611766
in
11767-
let mk_ast ~has_reason_react_jsx : string =
11767+
let mk_ast =
1176811768
Ext_buffer.clear buf;
1176911769
Ext_buffer.add_string buf bsc;
1177011770
Ext_buffer.add_char_string buf ' ' warnings;
@@ -11782,11 +11782,11 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config option)
1178211782
| None -> ()
1178311783
| Some flag ->
1178411784
Ext_buffer.add_char_string buf ' ' (Bsb_build_util.pp_flag flag));
11785-
(match (has_reason_react_jsx, reason_react_jsx, jsx_version) with
11786-
| _, _, Some Jsx_v3 -> Ext_buffer.add_string buf " -bs-jsx 3"
11787-
| _, _, Some Jsx_v4 -> Ext_buffer.add_string buf " -bs-jsx 4"
11788-
| _, Some Jsx_v3, None -> Ext_buffer.add_string buf " -bs-jsx 3"
11789-
| _ -> ());
11785+
(match (reason_react_jsx, jsx_version) with
11786+
| _, Some Jsx_v3 -> Ext_buffer.add_string buf " -bs-jsx 3"
11787+
| _, Some Jsx_v4 -> Ext_buffer.add_string buf " -bs-jsx 4"
11788+
| Some Jsx_v3, None -> Ext_buffer.add_string buf " -bs-jsx 3"
11789+
| None, None -> ());
1179011790
(match jsx_module with
1179111791
| None -> ()
1179211792
| Some React -> Ext_buffer.add_string buf " -bs-jsx-module react");
@@ -11799,10 +11799,8 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config option)
1179911799
Ext_buffer.add_string buf " -absname -bs-ast -o $out $i";
1180011800
Ext_buffer.contents buf
1180111801
in
11802-
let build_ast = define ~command:(mk_ast ~has_reason_react_jsx:false) "ast" in
11803-
let build_ast_from_re =
11804-
define ~command:(mk_ast ~has_reason_react_jsx:true) "astj"
11805-
in
11802+
let build_ast = define ~command:mk_ast "ast" in
11803+
let build_ast_from_re = define ~command:mk_ast "astj" in
1180611804

1180711805
let copy_resources =
1180811806
define

0 commit comments

Comments
 (0)