@@ -4,7 +4,9 @@ open Asttypes
4
4
open Parsetree
5
5
open Longident
6
6
7
- let moduleAccessName config = String. capitalize_ascii config.Jsx_common. module_
7
+ let moduleAccessName config value =
8
+ String. capitalize_ascii config.Jsx_common. module_ ^ " ." ^ value
9
+ |> Longident. parse
8
10
9
11
let nolabel = Nolabel
10
12
@@ -384,10 +386,7 @@ let transformUppercaseCall3 ~config modulePath mapper jsxExprLoc callExprLoc
384
386
( labelled " children" ,
385
387
Exp. apply
386
388
(Exp. ident
387
- {
388
- txt = Ldot (Lident (moduleAccessName config), " array" );
389
- loc = Location. none;
390
- })
389
+ {txt = moduleAccessName config " array" ; loc = Location. none})
391
390
[(Nolabel , expression)] );
392
391
]
393
392
| _ ->
@@ -431,31 +430,17 @@ let transformUppercaseCall3 ~config modulePath mapper jsxExprLoc callExprLoc
431
430
match (! childrenArg, keyProp) with
432
431
| None , key :: _ ->
433
432
( Exp. ident
434
- {
435
- loc = Location. none;
436
- txt = Ldot (Lident (moduleAccessName config), " jsxKeyed" );
437
- },
433
+ {loc = Location. none; txt = moduleAccessName config " jsxKeyed" },
438
434
[key; (nolabel, unitExpr ~loc: Location. none)] )
439
435
| None , [] ->
440
- ( Exp. ident
441
- {
442
- loc = Location. none;
443
- txt = Ldot (Lident (moduleAccessName config), " jsx" );
444
- },
436
+ ( Exp. ident {loc = Location. none; txt = moduleAccessName config " jsx" },
445
437
[] )
446
438
| Some _ , key :: _ ->
447
439
( Exp. ident
448
- {
449
- loc = Location. none;
450
- txt = Ldot (Lident (moduleAccessName config), " jsxsKeyed" );
451
- },
440
+ {loc = Location. none; txt = moduleAccessName config " jsxsKeyed" },
452
441
[key; (nolabel, unitExpr ~loc: Location. none)] )
453
442
| Some _ , [] ->
454
- ( Exp. ident
455
- {
456
- loc = Location. none;
457
- txt = Ldot (Lident (moduleAccessName config), " jsxs" );
458
- },
443
+ ( Exp. ident {loc = Location. none; txt = moduleAccessName config " jsxs" },
459
444
[] )
460
445
in
461
446
Exp. apply ~loc: jsxExprLoc ~attrs jsxExpr
@@ -500,9 +485,9 @@ let transformLowercaseCall3 ~config mapper jsxExprLoc callExprLoc attrs
500
485
(* the new jsx transform *)
501
486
| "automatic" ->
502
487
let elementBinding =
503
- match moduleAccessName config with
504
- | "React " -> Lident " ReactDOM"
505
- | generic -> Ldot ( Lident generic, " DOM " )
488
+ match config.module_ |> String. lowercase_ascii with
489
+ | "react " -> Lident " ReactDOM"
490
+ | _generic -> moduleAccessName config " Elements "
506
491
in
507
492
508
493
let children, nonChildrenProps =
@@ -539,10 +524,7 @@ let transformLowercaseCall3 ~config mapper jsxExprLoc callExprLoc attrs
539
524
( labelled " children" ,
540
525
Exp. apply
541
526
(Exp. ident
542
- {
543
- txt = Ldot (Lident (moduleAccessName config), " array" );
544
- loc = Location. none;
545
- })
527
+ {txt = moduleAccessName config " array" ; loc = Location. none})
546
528
[(Nolabel , expression)] );
547
529
]
548
530
in
@@ -1203,10 +1185,7 @@ let transformStructureItem ~config item =
1203
1185
(* can't be an arrow because it will defensively uncurry *)
1204
1186
let newExternalType =
1205
1187
Ptyp_constr
1206
- ( {
1207
- loc = pstr_loc;
1208
- txt = Ldot (Lident (moduleAccessName config), " componentLike" );
1209
- },
1188
+ ( {loc = pstr_loc; txt = moduleAccessName config " componentLike" },
1210
1189
[retPropsType; innerType] )
1211
1190
in
1212
1191
let newStructure =
@@ -1321,10 +1300,7 @@ let transformSignatureItem ~config item =
1321
1300
(* can't be an arrow because it will defensively uncurry *)
1322
1301
let newExternalType =
1323
1302
Ptyp_constr
1324
- ( {
1325
- loc = psig_loc;
1326
- txt = Ldot (Lident (moduleAccessName config), " componentLike" );
1327
- },
1303
+ ( {loc = psig_loc; txt = moduleAccessName config " componentLike" },
1328
1304
[retPropsType; innerType] )
1329
1305
in
1330
1306
let newStructure =
@@ -1419,8 +1395,7 @@ let expr ~config mapper expression =
1419
1395
let fragment =
1420
1396
match config.mode with
1421
1397
| "automatic" ->
1422
- Exp. ident ~loc
1423
- {loc; txt = Ldot (Lident (moduleAccessName config), " jsxFragment" )}
1398
+ Exp. ident ~loc {loc; txt = moduleAccessName config " jsxFragment" }
1424
1399
| "classic" | _ ->
1425
1400
Exp. ident ~loc {loc; txt = Ldot (Lident " React" , " fragment" )}
1426
1401
in
@@ -1431,10 +1406,7 @@ let expr ~config mapper expression =
1431
1406
let applyJsxArray expr =
1432
1407
Exp. apply
1433
1408
(Exp. ident
1434
- {
1435
- txt = Ldot (Lident (moduleAccessName config), " array" );
1436
- loc = Location. none;
1437
- })
1409
+ {txt = moduleAccessName config " array" ; loc = Location. none})
1438
1410
[(Nolabel , expr)]
1439
1411
in
1440
1412
let countOfChildren = function
@@ -1472,11 +1444,8 @@ let expr ~config mapper expression =
1472
1444
(match config.mode with
1473
1445
| "automatic" ->
1474
1446
if countOfChildren childrenExpr > 1 then
1475
- Exp. ident ~loc
1476
- {loc; txt = Ldot (Lident (moduleAccessName config), " jsxs" )}
1477
- else
1478
- Exp. ident ~loc
1479
- {loc; txt = Ldot (Lident (moduleAccessName config), " jsx" )}
1447
+ Exp. ident ~loc {loc; txt = moduleAccessName config " jsxs" }
1448
+ else Exp. ident ~loc {loc; txt = moduleAccessName config " jsx" }
1480
1449
| "classic" | _ ->
1481
1450
if countOfChildren childrenExpr > 1 then
1482
1451
Exp. ident ~loc
0 commit comments