@@ -37,13 +37,17 @@ type spec = {
3737 suffix : Ext_js_suffix .t
3838}
3939
40+ (* FIXME: use assoc list instead *)
4041module Spec_set = Set. Make ( struct type t = spec
4142 let compare = Pervasives. compare
4243 end )
4344
4445type t = {
4546 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+ *)
4751}
4852
4953let (.?() ) = Map_string. find_opt
@@ -147,10 +151,13 @@ let package_flag ({format; in_source; suffix } : spec) dir =
147151(* FIXME: we should adapt it *)
148152let package_flag_of_package_specs (package_specs : t )
149153 ~(dirname : string ) : string =
150- Spec_set. fold (fun format acc ->
154+ let res = Spec_set. fold (fun format acc ->
151155 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
154161let default_package_specs suffix =
155162 Spec_set. singleton
156163 { format = NodeJS ; in_source = false ; suffix }
@@ -202,13 +209,20 @@ let extract_bs_suffix_exn (map : json_map) : Ext_js_suffix.t =
202209 Bsb_exception. config_error config
203210 " expect a string exteion like \" .js\" here"
204211
205- let from_map map =
212+ let from_map ~( cwd :string ) map =
206213 let suffix = extract_bs_suffix_exn map in
207214 let modules = match map.?(Bsb_build_schemas. package_specs) with
208215 | Some x ->
209216 from_json suffix x
210217 | 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
211224 {
225+ runtime;
212226 modules
213227 }
214228
0 commit comments