@@ -4,7 +4,9 @@ open Asttypes
44open Parsetree
55open Longident
66
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
810
911let nolabel = Nolabel
1012
@@ -384,10 +386,7 @@ let transformUppercaseCall3 ~config modulePath mapper jsxExprLoc callExprLoc
384386 ( labelled " children" ,
385387 Exp. apply
386388 (Exp. ident
387- {
388- txt = Ldot (Lident (moduleAccessName config), " array" );
389- loc = Location. none;
390- })
389+ {txt = moduleAccessName config " array" ; loc = Location. none})
391390 [(Nolabel , expression)] );
392391 ]
393392 | _ ->
@@ -431,31 +430,17 @@ let transformUppercaseCall3 ~config modulePath mapper jsxExprLoc callExprLoc
431430 match (! childrenArg, keyProp) with
432431 | None , key :: _ ->
433432 ( Exp. ident
434- {
435- loc = Location. none;
436- txt = Ldot (Lident (moduleAccessName config), " jsxKeyed" );
437- },
433+ {loc = Location. none; txt = moduleAccessName config " jsxKeyed" },
438434 [key; (nolabel, unitExpr ~loc: Location. none)] )
439435 | 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" },
445437 [] )
446438 | Some _ , key :: _ ->
447439 ( Exp. ident
448- {
449- loc = Location. none;
450- txt = Ldot (Lident (moduleAccessName config), " jsxsKeyed" );
451- },
440+ {loc = Location. none; txt = moduleAccessName config " jsxsKeyed" },
452441 [key; (nolabel, unitExpr ~loc: Location. none)] )
453442 | 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" },
459444 [] )
460445 in
461446 Exp. apply ~loc: jsxExprLoc ~attrs jsxExpr
@@ -500,9 +485,9 @@ let transformLowercaseCall3 ~config mapper jsxExprLoc callExprLoc attrs
500485 (* the new jsx transform *)
501486 | "automatic" ->
502487 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 "
506491 in
507492
508493 let children, nonChildrenProps =
@@ -539,10 +524,7 @@ let transformLowercaseCall3 ~config mapper jsxExprLoc callExprLoc attrs
539524 ( labelled " children" ,
540525 Exp. apply
541526 (Exp. ident
542- {
543- txt = Ldot (Lident (moduleAccessName config), " array" );
544- loc = Location. none;
545- })
527+ {txt = moduleAccessName config " array" ; loc = Location. none})
546528 [(Nolabel , expression)] );
547529 ]
548530 in
@@ -1203,10 +1185,7 @@ let transformStructureItem ~config item =
12031185 (* can't be an arrow because it will defensively uncurry *)
12041186 let newExternalType =
12051187 Ptyp_constr
1206- ( {
1207- loc = pstr_loc;
1208- txt = Ldot (Lident (moduleAccessName config), " componentLike" );
1209- },
1188+ ( {loc = pstr_loc; txt = moduleAccessName config " componentLike" },
12101189 [retPropsType; innerType] )
12111190 in
12121191 let newStructure =
@@ -1321,10 +1300,7 @@ let transformSignatureItem ~config item =
13211300 (* can't be an arrow because it will defensively uncurry *)
13221301 let newExternalType =
13231302 Ptyp_constr
1324- ( {
1325- loc = psig_loc;
1326- txt = Ldot (Lident (moduleAccessName config), " componentLike" );
1327- },
1303+ ( {loc = psig_loc; txt = moduleAccessName config " componentLike" },
13281304 [retPropsType; innerType] )
13291305 in
13301306 let newStructure =
@@ -1419,8 +1395,7 @@ let expr ~config mapper expression =
14191395 let fragment =
14201396 match config.mode with
14211397 | "automatic" ->
1422- Exp. ident ~loc
1423- {loc; txt = Ldot (Lident (moduleAccessName config), " jsxFragment" )}
1398+ Exp. ident ~loc {loc; txt = moduleAccessName config " jsxFragment" }
14241399 | "classic" | _ ->
14251400 Exp. ident ~loc {loc; txt = Ldot (Lident " React" , " fragment" )}
14261401 in
@@ -1431,10 +1406,7 @@ let expr ~config mapper expression =
14311406 let applyJsxArray expr =
14321407 Exp. apply
14331408 (Exp. ident
1434- {
1435- txt = Ldot (Lident (moduleAccessName config), " array" );
1436- loc = Location. none;
1437- })
1409+ {txt = moduleAccessName config " array" ; loc = Location. none})
14381410 [(Nolabel , expr)]
14391411 in
14401412 let countOfChildren = function
@@ -1472,11 +1444,8 @@ let expr ~config mapper expression =
14721444 (match config.mode with
14731445 | "automatic" ->
14741446 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" }
14801449 | "classic" | _ ->
14811450 if countOfChildren childrenExpr > 1 then
14821451 Exp. ident ~loc
0 commit comments