Skip to content

Commit fb6b4b7

Browse files
committed
record types, prepare move away package_name
1 parent 80a89e7 commit fb6b4b7

File tree

4 files changed

+40
-20
lines changed

4 files changed

+40
-20
lines changed

jscomp/core/js_name_of_module_id.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ let fix_path_for_windows : string -> string =
4545

4646
let get_runtime_module_path
4747
(dep_module_id : Lam_module_ident.t)
48-
current_package_info
48+
(current_package_info : Js_packages_info.t)
4949
module_system =
5050
let current_info_query =
5151
Js_packages_info.query_package_infos current_package_info
@@ -55,7 +55,7 @@ let get_runtime_module_path
5555
| Package_not_found -> assert false
5656
| Package_script ->
5757
Js_packages_info.runtime_package_path module_system js_file
58-
| Package_found(_, cur_path) ->
58+
| Package_found { rel_path = cur_path} ->
5959
let dep_path =
6060
"lib" // Js_packages_info.runtime_dir_of_module_system module_system in
6161
if Js_packages_info.is_runtime_package current_package_info then
@@ -127,7 +127,7 @@ let string_of_module_id
127127
Bs_exception.error (Dependency_script_module_dependent_not js_file)
128128
| (Package_script | Package_found _ ), Package_not_found -> assert false
129129

130-
| Package_found(dep_package_name, dep_path),
130+
| Package_found {name = dep_package_name; rel_path = dep_path},
131131
Package_script
132132
->
133133
#if BS_NATIVE then
@@ -139,8 +139,8 @@ let string_of_module_id
139139
dep_package_name // dep_path // js_file
140140
#end
141141

142-
| Package_found(dep_package_name, dep_path),
143-
Package_found(cur_package_name, cur_path) ->
142+
| Package_found {name = dep_package_name; rel_path = dep_path},
143+
Package_found {name = cur_package_name; rel_path = cur_path} ->
144144
if Js_packages_info.same_package_by_name current_package_info dep_package_info then
145145
Ext_path.node_rebase_file
146146
~from:cur_path

jscomp/core/js_packages_info.ml

+8-3
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,15 @@ let dump_packages_info
143143
dump_package_info
144144
) ls
145145

146+
type package_found_info =
147+
{
148+
name : package_name ;
149+
rel_path : string ;
150+
}
146151
type info_query =
147152
| Package_script
148-
| Package_found of package_name * string
149153
| Package_not_found
150-
154+
| Package_found of package_found_info
151155

152156

153157
let query_package_infos
@@ -157,7 +161,8 @@ let query_package_infos
157161
else
158162
match Ext_list.find_first package_info.module_systems (fun k ->
159163
compatible k.module_system module_system) with
160-
| Some k -> Package_found (package_info.name, k.path)
164+
| Some k ->
165+
Package_found {name = package_info.name; rel_path = k.path}
161166
| None -> Package_not_found
162167

163168

jscomp/core/js_packages_info.mli

+7-2
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,16 @@ val add_npm_package_path :
8080
string ->
8181
t
8282

83+
type package_found_info =
84+
{
85+
name : package_name ;
86+
rel_path : string ;
87+
}
88+
8389
type info_query =
8490
| Package_script
85-
| Package_found of package_name * string
8691
| Package_not_found
87-
92+
| Package_found of package_found_info
8893

8994
val get_output_dir:
9095
t ->

lib/whole_compiler.ml

+20-10
Original file line numberDiff line numberDiff line change
@@ -60437,11 +60437,16 @@ val add_npm_package_path :
6043760437
string ->
6043860438
t
6043960439

60440+
type package_found_info =
60441+
{
60442+
name : package_name ;
60443+
rel_path : string ;
60444+
}
60445+
6044060446
type info_query =
6044160447
| Package_script
60442-
| Package_found of package_name * string
6044360448
| Package_not_found
60444-
60449+
| Package_found of package_found_info
6044560450

6044660451
val get_output_dir:
6044760452
t ->
@@ -60606,11 +60611,15 @@ let dump_packages_info
6060660611
dump_package_info
6060760612
) ls
6060860613

60614+
type package_found_info =
60615+
{
60616+
name : package_name ;
60617+
rel_path : string ;
60618+
}
6060960619
type info_query =
6061060620
| Package_script
60611-
| Package_found of package_name * string
6061260621
| Package_not_found
60613-
60622+
| Package_found of package_found_info
6061460623

6061560624

6061660625
let query_package_infos
@@ -60620,7 +60629,8 @@ let query_package_infos
6062060629
else
6062160630
match Ext_list.find_first package_info.module_systems (fun k ->
6062260631
compatible k.module_system module_system) with
60623-
| Some k -> Package_found (package_info.name, k.path)
60632+
| Some k ->
60633+
Package_found {name = package_info.name; rel_path = k.path}
6062460634
| None -> Package_not_found
6062560635

6062660636

@@ -86238,7 +86248,7 @@ let fix_path_for_windows : string -> string =
8623886248

8623986249
let get_runtime_module_path
8624086250
(dep_module_id : Lam_module_ident.t)
86241-
current_package_info
86251+
(current_package_info : Js_packages_info.t)
8624286252
module_system =
8624386253
let current_info_query =
8624486254
Js_packages_info.query_package_infos current_package_info
@@ -86248,7 +86258,7 @@ let get_runtime_module_path
8624886258
| Package_not_found -> assert false
8624986259
| Package_script ->
8625086260
Js_packages_info.runtime_package_path module_system js_file
86251-
| Package_found(_, cur_path) ->
86261+
| Package_found { rel_path = cur_path} ->
8625286262
let dep_path =
8625386263
"lib" // Js_packages_info.runtime_dir_of_module_system module_system in
8625486264
if Js_packages_info.is_runtime_package current_package_info then
@@ -86320,15 +86330,15 @@ let string_of_module_id
8632086330
Bs_exception.error (Dependency_script_module_dependent_not js_file)
8632186331
| (Package_script | Package_found _ ), Package_not_found -> assert false
8632286332

86323-
| Package_found(dep_package_name, dep_path),
86333+
| Package_found {name = dep_package_name; rel_path = dep_path},
8632486334
Package_script
8632586335
->
8632686336

8632786337
dep_package_name // dep_path // js_file
8632886338

8632986339

86330-
| Package_found(dep_package_name, dep_path),
86331-
Package_found(cur_package_name, cur_path) ->
86340+
| Package_found {name = dep_package_name; rel_path = dep_path},
86341+
Package_found {name = cur_package_name; rel_path = cur_path} ->
8633286342
if Js_packages_info.same_package_by_name current_package_info dep_package_info then
8633386343
Ext_path.node_rebase_file
8633486344
~from:cur_path

0 commit comments

Comments
 (0)