Skip to content

Commit 547dfca

Browse files
committed
Poor man feature flag
1 parent 3d2930e commit 547dfca

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

compiler/bsc/rescript_compiler_main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ let buckle_script_flags : (string * Bsc_args.spec * string) array =
237237
"*internal* <module> Opens the module <module> before typing" );
238238
( "-bs-jsx",
239239
string_call (fun i ->
240-
if i <> "3" && i <> "4" then
240+
if i <> "3" && i <> "4" && i <> "5" then
241241
Bsc_args.bad_arg (" Not supported jsx version : " ^ i);
242242
Js_config.jsx_version :=
243243
Js_config.jsx_version_of_int @@ int_of_string i),

compiler/common/js_config.ml

Lines changed: 3 additions & 2 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_v4
27+
type jsx_version = Jsx_v4 | Jsx_preserve
2828
type jsx_module = React | Generic of {module_name: string}
2929

3030
let no_version_header = ref false
@@ -56,13 +56,14 @@ let no_stdlib = ref false
5656
let no_export = ref false
5757
let int_of_jsx_version = function
5858
| Jsx_v4 -> 4
59-
59+
| Jsx_preserve -> 5
6060
let string_of_jsx_module = function
6161
| React -> "react"
6262
| Generic {module_name} -> module_name
6363

6464
let jsx_version_of_int = function
6565
| 4 -> Some Jsx_v4
66+
| 5 -> Some Jsx_preserve
6667
| _ -> None
6768

6869
let jsx_module_of_string = function

compiler/common/js_config.mli

Lines changed: 1 addition & 1 deletion
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_v4
25+
type jsx_version = Jsx_v4 | Jsx_preserve
2626
type jsx_module = React | Generic of {module_name: string}
2727

2828
(* val get_packages_info :

compiler/syntax/src/jsx_ppx.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ let get_mapper ~config =
7777

7878
let expr mapper e =
7979
match config.version with
80-
| 4 -> expr4 mapper e
80+
| 4 | 5 -> expr4 mapper e
8181
| _ -> default_mapper.expr mapper e
8282
in
8383
let module_binding mapper mb =
8484
match config.version with
85-
| 4 -> module_binding4 mapper mb
85+
| 4 | 5 -> module_binding4 mapper mb
8686
| _ -> default_mapper.module_binding mapper mb
8787
in
8888
let save_config () =

compiler/syntax/src/jsx_v4.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ let mk_react_jsx (config : Jsx_common.jsx_config) mapper loc attrs
12771277
[key_prop; (nolabel, unit_expr ~loc:Location.none)] )
12781278
in
12791279
let args = [(nolabel, elementTag); (nolabel, props_record)] @ key_and_unit in
1280-
Exp.apply ~loc ~attrs ~transformed_jsx:true jsx_expr args
1280+
Exp.apply ~loc ~attrs ~transformed_jsx:(config.version = 5) jsx_expr args
12811281

12821282
(* In most situations, the component name is the make function from a module.
12831283
However, if the name contains a lowercase letter, it means it probably an external component.

0 commit comments

Comments
 (0)