File tree Expand file tree Collapse file tree 5 files changed +86
-14
lines changed Expand file tree Collapse file tree 5 files changed +86
-14
lines changed Original file line number Diff line number Diff line change @@ -87,11 +87,29 @@ let translate ?output_prefix loc (cxt : Lam_compile_context.t)
87
87
match output_prefix with
88
88
| Some output_prefix ->
89
89
let output_dir = Filename. dirname output_prefix in
90
- (* TODO: construct J.module_id from e *)
91
- let id = Ident. create " Belt_List" in
90
+
91
+ (* TODO: pull this function out to top-level *)
92
+ let rec module_names_of_expression = function
93
+ | J. Var (J. Qualified ({ id = { name } } , _ )) -> [ name ]
94
+ | J. Caml_block (exprs , _ , _ , _ ) ->
95
+ exprs
96
+ |> List. map (fun (e : J.expression ) ->
97
+ module_names_of_expression e.expression_desc)
98
+ |> List. concat
99
+ | _ -> []
100
+ in
101
+
102
+ let module_name =
103
+ match module_names_of_expression e.expression_desc with
104
+ | [ module_name ] -> module_name
105
+ | _ -> assert false
106
+ (* TODO: graceful error message here *)
107
+ in
108
+
92
109
let path =
93
110
Js_name_of_module_id. string_of_module_id
94
- { id; kind = Js_op. Ml } ~output_dir
111
+ { id = Ident. create module_name; kind = Js_op. Ml }
112
+ ~output_dir
95
113
(* TODO: where is Js_package_info.module_system ? *)
96
114
Js_packages_info. NodeJS
97
115
in
Original file line number Diff line number Diff line change @@ -3,6 +3,6 @@ let each = Js.import(Belt.List.forEach)
3
3
let eachInt = (list : list <int >, f : int => unit ) =>
4
4
Js .Promise .then_ (each => list -> each (f )-> Js .Promise .resolve , each )
5
5
6
- module type Belt = module type of Belt
6
+ module type BeltList = module type of Belt . List
7
7
8
- let beltAsModule = Js .import (module (Belt : Belt ))
8
+ let beltAsModule = Js .import (module (Belt . List : BeltList ))
Original file line number Diff line number Diff line change @@ -96699,11 +96699,29 @@ let translate ?output_prefix loc (cxt : Lam_compile_context.t)
96699
96699
match output_prefix with
96700
96700
| Some output_prefix ->
96701
96701
let output_dir = Filename.dirname output_prefix in
96702
- (* TODO: construct J.module_id from e *)
96703
- let id = Ident.create "Belt_List" in
96702
+
96703
+ (* TODO: pull this function out to top-level *)
96704
+ let rec module_names_of_expression = function
96705
+ | J.Var (J.Qualified ({ id = { name } }, _)) -> [ name ]
96706
+ | J.Caml_block (exprs, _, _, _) ->
96707
+ exprs
96708
+ |> List.map (fun (e : J.expression) ->
96709
+ module_names_of_expression e.expression_desc)
96710
+ |> List.concat
96711
+ | _ -> []
96712
+ in
96713
+
96714
+ let module_name =
96715
+ match module_names_of_expression e.expression_desc with
96716
+ | [ module_name ] -> module_name
96717
+ | _ -> assert false
96718
+ (* TODO: graceful error message here *)
96719
+ in
96720
+
96704
96721
let path =
96705
96722
Js_name_of_module_id.string_of_module_id
96706
- { id; kind = Js_op.Ml } ~output_dir
96723
+ { id = Ident.create module_name; kind = Js_op.Ml }
96724
+ ~output_dir
96707
96725
(* TODO: where is Js_package_info.module_system ? *)
96708
96726
Js_packages_info.NodeJS
96709
96727
in
Original file line number Diff line number Diff line change @@ -96699,11 +96699,29 @@ let translate ?output_prefix loc (cxt : Lam_compile_context.t)
96699
96699
match output_prefix with
96700
96700
| Some output_prefix ->
96701
96701
let output_dir = Filename.dirname output_prefix in
96702
- (* TODO: construct J.module_id from e *)
96703
- let id = Ident.create "Belt_List" in
96702
+
96703
+ (* TODO: pull this function out to top-level *)
96704
+ let rec module_names_of_expression = function
96705
+ | J.Var (J.Qualified ({ id = { name } }, _)) -> [ name ]
96706
+ | J.Caml_block (exprs, _, _, _) ->
96707
+ exprs
96708
+ |> List.map (fun (e : J.expression) ->
96709
+ module_names_of_expression e.expression_desc)
96710
+ |> List.concat
96711
+ | _ -> []
96712
+ in
96713
+
96714
+ let module_name =
96715
+ match module_names_of_expression e.expression_desc with
96716
+ | [ module_name ] -> module_name
96717
+ | _ -> assert false
96718
+ (* TODO: graceful error message here *)
96719
+ in
96720
+
96704
96721
let path =
96705
96722
Js_name_of_module_id.string_of_module_id
96706
- { id; kind = Js_op.Ml } ~output_dir
96723
+ { id = Ident.create module_name; kind = Js_op.Ml }
96724
+ ~output_dir
96707
96725
(* TODO: where is Js_package_info.module_system ? *)
96708
96726
Js_packages_info.NodeJS
96709
96727
in
Original file line number Diff line number Diff line change @@ -265893,11 +265893,29 @@ let translate ?output_prefix loc (cxt : Lam_compile_context.t)
265893
265893
match output_prefix with
265894
265894
| Some output_prefix ->
265895
265895
let output_dir = Filename.dirname output_prefix in
265896
- (* TODO: construct J.module_id from e *)
265897
- let id = Ident.create "Belt_List" in
265896
+
265897
+ (* TODO: pull this function out to top-level *)
265898
+ let rec module_names_of_expression = function
265899
+ | J.Var (J.Qualified ({ id = { name } }, _)) -> [ name ]
265900
+ | J.Caml_block (exprs, _, _, _) ->
265901
+ exprs
265902
+ |> List.map (fun (e : J.expression) ->
265903
+ module_names_of_expression e.expression_desc)
265904
+ |> List.concat
265905
+ | _ -> []
265906
+ in
265907
+
265908
+ let module_name =
265909
+ match module_names_of_expression e.expression_desc with
265910
+ | [ module_name ] -> module_name
265911
+ | _ -> assert false
265912
+ (* TODO: graceful error message here *)
265913
+ in
265914
+
265898
265915
let path =
265899
265916
Js_name_of_module_id.string_of_module_id
265900
- { id; kind = Js_op.Ml } ~output_dir
265917
+ { id = Ident.create module_name; kind = Js_op.Ml }
265918
+ ~output_dir
265901
265919
(* TODO: where is Js_package_info.module_system ? *)
265902
265920
Js_packages_info.NodeJS
265903
265921
in
You can’t perform that action at this time.
0 commit comments