@@ -127,9 +127,19 @@ let unnamespace_module_name file_name =
127127 | Some index -> String. sub file_name 0 index
128128 | None -> (
129129 match Ext_namespace. try_split_module_name file_name with
130- | Some (module_name , _namespace ) -> module_name
130+ | Some (_namespace , module_name ) -> module_name
131131 | None -> file_name)
132132
133+ let maybe_hoist_nested_make_component ~(config : Jsx_common.jsx_config )
134+ ~empty_loc ~full_module_name fn_name =
135+ match (fn_name, config.nested_modules) with
136+ | "make" , _ :: _ ->
137+ config.hoisted_structure_items < -
138+ make_hoisted_component_binding ~empty_loc ~full_module_name
139+ config.nested_modules
140+ :: config.hoisted_structure_items
141+ | _ -> ()
142+
133143(* Build a string representation of a module name with segments separated by $ *)
134144let make_module_name file_name nested_modules fn_name =
135145 let file_name = unnamespace_module_name file_name in
@@ -843,13 +853,8 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name ~rec_flag binding =
843853 Some (binding_wrapper full_expression) )
844854 in
845855 let () =
846- match (fn_name, config.nested_modules) with
847- | "make" , _ :: _ ->
848- config.hoisted_structure_items < -
849- make_hoisted_component_binding ~empty_loc ~full_module_name
850- config.nested_modules
851- :: config.hoisted_structure_items
852- | _ -> ()
856+ maybe_hoist_nested_make_component ~config ~empty_loc ~full_module_name
857+ fn_name
853858 in
854859 (Some props_record_type, binding, new_binding))
855860 else if Jsx_common. has_attr_on_binding Jsx_common. has_attr_with_props binding
@@ -981,7 +986,8 @@ let transform_structure_item ~config item =
981986 | {
982987 pstr_loc;
983988 pstr_desc =
984- Pstr_primitive ({pval_attributes; pval_type} as value_description);
989+ Pstr_primitive
990+ ({pval_attributes; pval_type; pval_name} as value_description);
985991 } as pstr -> (
986992 match
987993 ( List. filter Jsx_common. has_attr pval_attributes,
@@ -1042,6 +1048,15 @@ let transform_structure_item ~config item =
10421048 };
10431049 }
10441050 in
1051+ let file_name = filename_from_loc pstr_loc in
1052+ let empty_loc = Location. in_file file_name in
1053+ let full_module_name =
1054+ make_module_name file_name config.nested_modules pval_name.txt
1055+ in
1056+ let () =
1057+ maybe_hoist_nested_make_component ~config ~empty_loc ~full_module_name
1058+ pval_name.txt
1059+ in
10451060 [props_record_type; new_structure]
10461061 | _ ->
10471062 Jsx_common. raise_error ~loc: pstr_loc
0 commit comments