@@ -37,13 +37,17 @@ type spec = {
37
37
suffix : Ext_js_suffix .t
38
38
}
39
39
40
+ (* FIXME: use assoc list instead *)
40
41
module Spec_set = Set. Make ( struct type t = spec
41
42
let compare = Pervasives. compare
42
43
end )
43
44
44
45
type t = {
45
46
modules : Spec_set .t ;
46
- (* runtime: Bsb_pkg_types.t option; *)
47
+ runtime : string option ;
48
+ (* This has to be resolved as early as possible, since
49
+ the path will be inherited in sub projects
50
+ *)
47
51
}
48
52
49
53
let (.?() ) = Map_string. find_opt
@@ -147,10 +151,13 @@ let package_flag ({format; in_source; suffix } : spec) dir =
147
151
(* FIXME: we should adapt it *)
148
152
let package_flag_of_package_specs (package_specs : t )
149
153
~(dirname : string ) : string =
150
- Spec_set. fold (fun format acc ->
154
+ let res = Spec_set. fold (fun format acc ->
151
155
Ext_string. inter2 acc (package_flag format dirname )
152
- ) package_specs.modules Ext_string. empty
153
-
156
+ ) package_specs.modules Ext_string. empty in
157
+ match package_specs.runtime with
158
+ | None -> res
159
+ | Some x ->
160
+ res ^ " -runtime " ^ x
154
161
let default_package_specs suffix =
155
162
Spec_set. singleton
156
163
{ format = NodeJS ; in_source = false ; suffix }
@@ -202,13 +209,20 @@ let extract_bs_suffix_exn (map : json_map) : Ext_js_suffix.t =
202
209
Bsb_exception. config_error config
203
210
" expect a string exteion like \" .js\" here"
204
211
205
- let from_map map =
212
+ let from_map ~( cwd :string ) map =
206
213
let suffix = extract_bs_suffix_exn map in
207
214
let modules = match map.?(Bsb_build_schemas. package_specs) with
208
215
| Some x ->
209
216
from_json suffix x
210
217
| None -> default_package_specs suffix in
218
+ let runtime =
219
+ match map.?(Bsb_build_schemas. external_stdlib) with
220
+ | None -> None
221
+ | Some (Str{str; _} ) ->
222
+ Some (Bsb_pkg. resolve_bs_package ~cwd (Bsb_pkg_types. string_as_package str))
223
+ | _ -> assert false in
211
224
{
225
+ runtime;
212
226
modules
213
227
}
214
228
0 commit comments