diff --git a/jscomp/bsb/bsb_config_parse.ml b/jscomp/bsb/bsb_config_parse.ml index 91e10d7a56..69fcdb0523 100644 --- a/jscomp/bsb/bsb_config_parse.ml +++ b/jscomp/bsb/bsb_config_parse.ml @@ -25,7 +25,7 @@ (* let get_list_string = Bsb_build_util.get_list_string *) let (//) = Ext_path.combine -let current_package : Bsb_pkg_types.t = Global Bs_version.package_name + let resolve_package cwd package_name = let x = Bsb_pkg.resolve_bs_package ~cwd package_name in { @@ -113,6 +113,7 @@ let check_stdlib (map : json_map) cwd (*built_in_package*) = | None | Some _ -> begin + let current_package : Bsb_pkg_types.t = Global !Bs_version.package_name in if Sys.getenv_opt "RES_SKIP_STDLIB_CHECK" = None then begin let stdlib_path = Bsb_pkg.resolve_bs_package ~cwd current_package in diff --git a/jscomp/bsb/bsb_exception.ml b/jscomp/bsb/bsb_exception.ml index d32a8d4bb1..d65f83ee83 100644 --- a/jscomp/bsb/bsb_exception.ml +++ b/jscomp/bsb/bsb_exception.ml @@ -57,12 +57,12 @@ let print (fmt : Format.formatter) (x : error) = | None -> Ext_string.empty | Some x -> " in " ^ x in let name = Bsb_pkg_types.to_string name in - if Ext_string.equal name Bs_version.package_name then + if Ext_string.equal name !Bs_version.package_name then Format.fprintf fmt "File \"bsconfig.json\", line 1\n\ - @{Error:@} package @{bs-platform@} is not found %s\n\ + @{Error:@} package @{%s@} is not found %s\n\ It's the basic, required package. If you have it installed globally,\n\ - Please run `npm link bs-platform` to make it available" in_json + Please run `npm link bs-platform` to make it available" name in_json else Format.fprintf fmt "File \"bsconfig.json\", line 1\n\ diff --git a/jscomp/build_version.js b/jscomp/build_version.js index f764237191..9ea96587f5 100644 --- a/jscomp/build_version.js +++ b/jscomp/build_version.js @@ -42,7 +42,7 @@ fs.writeFileSync( let version = "${version}" let header = "// Generated by ReScript, PLEASE EDIT WITH CARE" -let package_name = "${name}" +let package_name = ref "${name}" `, "utf8" ); diff --git a/jscomp/common/bs_version.ml b/jscomp/common/bs_version.ml index dbaf0fbd0b..1810b6f64b 100644 --- a/jscomp/common/bs_version.ml +++ b/jscomp/common/bs_version.ml @@ -22,8 +22,8 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let version = "8.4.0" +let version = "8.5.0" let header = "// Generated by ReScript, PLEASE EDIT WITH CARE" -let package_name = "bs-platform" +let package_name = ref "bs-platform" \ No newline at end of file diff --git a/jscomp/common/bs_version.mli b/jscomp/common/bs_version.mli index 3a6094e3a7..cb5c2022ec 100644 --- a/jscomp/common/bs_version.mli +++ b/jscomp/common/bs_version.mli @@ -26,4 +26,4 @@ val version : string val header : string -val package_name : string \ No newline at end of file +val package_name : string ref \ No newline at end of file diff --git a/jscomp/core/js_name_of_module_id.ml b/jscomp/core/js_name_of_module_id.ml index a4282e1037..172d8f545a 100644 --- a/jscomp/core/js_name_of_module_id.ml +++ b/jscomp/core/js_name_of_module_id.ml @@ -34,6 +34,7 @@ let fix_path_for_windows : string -> string = else fun s -> s +(* dependency is runtime module *) let get_runtime_module_path (dep_module_id : Lam_module_ident.t) (current_package_info : Js_packages_info.t) diff --git a/jscomp/core/js_packages_info.ml b/jscomp/core/js_packages_info.ml index 228e8fcf06..27eab46e07 100644 --- a/jscomp/core/js_packages_info.ml +++ b/jscomp/core/js_packages_info.ml @@ -56,7 +56,7 @@ type package_name = -let runtime_package_name = "bs-platform" + let (//) = Filename.concat @@ -70,7 +70,7 @@ let runtime_dir_of_module_system (ms : module_system ) = let runtime_package_path (ms : module_system) js_file = - runtime_package_name // "lib" // runtime_dir_of_module_system ms // js_file + !Bs_version.package_name // "lib" // runtime_dir_of_module_system ms // js_file type t = @@ -86,6 +86,14 @@ let runtime_package_specs : t = { {module_system = NodeJS; path = "lib/js"; suffix = Js}; ] } + +(** + populated by the command line +*) +let runtime_test_package_specs : t = { + name = Pkg_runtime; + module_systems = [] +} let same_package_by_name (x : t) (y : t) = x.name = y.name let is_runtime_package (x : t) = @@ -112,16 +120,10 @@ let empty : t = module_systems = [] } -let from_name (name : string) = - if name = runtime_package_name then - { - name = Pkg_runtime ; module_systems = [] - } - else - { - name = Pkg_normal name ; - module_systems = [] - } +let from_name (name : string) : t = { + name = Pkg_normal name ; + module_systems = [] +} let is_empty (x : t) = x.name = Pkg_empty @@ -156,7 +158,7 @@ let dump_package_name fmt (x : package_name) = match x with | Pkg_empty -> Format.fprintf fmt "@empty_pkg@" | Pkg_normal s -> Format.pp_print_string fmt s - | Pkg_runtime -> Format.pp_print_string fmt runtime_package_name + | Pkg_runtime -> Format.pp_print_string fmt "@runtime" let dump_packages_info (fmt : Format.formatter) @@ -208,7 +210,7 @@ let query_package_infos compatible k.module_system module_system) with | Some k -> let rel_path = k.path in - let pkg_rel_path = runtime_package_name // rel_path in + let pkg_rel_path = !Bs_version.package_name // rel_path in Package_found { rel_path ; @@ -221,7 +223,8 @@ let query_package_infos let get_js_path (x : t ) - module_system + (module_system : module_system) + : string = match Ext_list.find_first x.module_systems (fun k -> compatible k.module_system module_system) with diff --git a/jscomp/core/js_packages_info.mli b/jscomp/core/js_packages_info.mli index 836054197b..36ed0ce24e 100644 --- a/jscomp/core/js_packages_info.mli +++ b/jscomp/core/js_packages_info.mli @@ -47,6 +47,9 @@ type package_info = { type t val runtime_package_specs : t + +val runtime_test_package_specs : t + val is_runtime_package: t -> bool diff --git a/jscomp/core/js_packages_state.ml b/jscomp/core/js_packages_state.ml index 19e72d7f11..38c9f2f447 100644 --- a/jscomp/core/js_packages_state.ml +++ b/jscomp/core/js_packages_state.ml @@ -33,6 +33,11 @@ let set_package_name name = else Bsc_args.bad_arg "duplicated flag for -bs-package-name" +let make_runtime () : unit = + packages_info := Js_packages_info.runtime_package_specs + +let make_runtime_test () : unit = + packages_info := Js_packages_info.runtime_test_package_specs let set_package_map module_name = (* set_package_name name ; let module_name = Ext_namespace.namespace_of_package_name name in *) diff --git a/jscomp/core/js_packages_state.mli b/jscomp/core/js_packages_state.mli index 38b08d5faa..a73012be76 100644 --- a/jscomp/core/js_packages_state.mli +++ b/jscomp/core/js_packages_state.mli @@ -26,6 +26,11 @@ val set_package_name : string -> unit +val make_runtime: + unit -> unit + +val make_runtime_test: + unit -> unit val set_package_map : string -> unit val get_packages_info : diff --git a/jscomp/main/js_main.ml b/jscomp/main/js_main.ml index 8fa2e11483..075b401397 100644 --- a/jscomp/main/js_main.ml +++ b/jscomp/main/js_main.ml @@ -443,7 +443,11 @@ let buckle_script_flags : (string * Bsc_args.spec * string) array = " Enable or disable error status for warnings according\n\ to . See option -w for the syntax of .\n\ Default setting is " ^ Bsc_warnings.defaults_warn_error; - + "-make-runtime", unit_call Js_packages_state.make_runtime, + "*internal* make runtime library"; + "-make-runtime-test", unit_call Js_packages_state.make_runtime_test, + "*internal* make runtime test library"; + |] diff --git a/jscomp/others/release.ninja b/jscomp/others/release.ninja index 668d646cad..afbc249077 100644 --- a/jscomp/others/release.ninja +++ b/jscomp/others/release.ninja @@ -1,5 +1,5 @@ -bsc_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -bs-package-name bs-platform -bs-package-output commonjs:lib/js -bs-package-output es6:lib/es6:.mjs -nopervasives -unsafe -w +50 -warn-error A -open Bs_stdlib_mini -I ./runtime +bsc_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A -open Bs_stdlib_mini -I ./runtime rule cc command = $bsc -bs-cmi -bs-cmj $bsc_flags -I others $in diff --git a/jscomp/runtime/release.ninja b/jscomp/runtime/release.ninja index 517d4a8db1..f7aedeca3d 100644 --- a/jscomp/runtime/release.ninja +++ b/jscomp/runtime/release.ninja @@ -1,5 +1,5 @@ -bsc_no_open_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -bs-package-name bs-platform -bs-package-output commonjs:lib/js -bs-package-output es6:lib/es6:.mjs -nopervasives -unsafe -w +50 -warn-error A +bsc_no_open_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A bsc_flags = $bsc_no_open_flags -open Bs_stdlib_mini rule cc diff --git a/jscomp/stdlib-406/release.ninja b/jscomp/stdlib-406/release.ninja index c201aaf1be..a771eab578 100644 --- a/jscomp/stdlib-406/release.ninja +++ b/jscomp/stdlib-406/release.ninja @@ -1,5 +1,5 @@ -bsc_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -bs-package-name bs-platform -bs-package-output commonjs:lib/js -bs-package-output es6:lib/es6:.mjs -w -9-3-106 -warn-error A -I runtime -I others +bsc_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -make-runtime -w -9-3-106 -warn-error A -I runtime -I others rule cc command = $bsc -bs-cmi -bs-cmj $bsc_flags -I stdlib-406 $in diff --git a/jscomp/test/build.ninja b/jscomp/test/build.ninja index 83e7a6eb9f..a83c8a2c41 100644 --- a/jscomp/test/build.ninja +++ b/jscomp/test/build.ninja @@ -1,5 +1,5 @@ -bsc_flags = -bs-no-version-header -bs-cross-module-opt -bs-package-name bs-platform -bs-package-output commonjs:jscomp/test -w -3-6-26-27-29-30-32..40-44-45-52-60-9-106+104 -warn-error A -I runtime -I $stdlib -I others +bsc_flags = -bs-no-version-header -bs-cross-module-opt -make-runtime-test -bs-package-output commonjs:jscomp/test -w -3-6-26-27-29-30-32..40-44-45-52-60-9-106+104 -warn-error A -I runtime -I $stdlib -I others rule cc command = $bsc -bs-cmi -bs-cmj $bsc_flags -I test $in diff --git a/lib/4.06.1/bsb.ml b/lib/4.06.1/bsb.ml index d3816a66bb..f25c7453c6 100644 --- a/lib/4.06.1/bsb.ml +++ b/lib/4.06.1/bsb.ml @@ -28,7 +28,7 @@ val version : string val header : string -val package_name : string +val package_name : string ref end = struct #1 "bs_version.ml" @@ -55,10 +55,10 @@ end = struct * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let version = "8.4.0" +let version = "8.5.0" let header = "// Generated by ReScript, PLEASE EDIT WITH CARE" -let package_name = "bs-platform" +let package_name = ref "bs-platform" end module Ext_array : sig @@ -6500,12 +6500,12 @@ let print (fmt : Format.formatter) (x : error) = | None -> Ext_string.empty | Some x -> " in " ^ x in let name = Bsb_pkg_types.to_string name in - if Ext_string.equal name Bs_version.package_name then + if Ext_string.equal name !Bs_version.package_name then Format.fprintf fmt "File \"bsconfig.json\", line 1\n\ - @{Error:@} package @{bs-platform@} is not found %s\n\ + @{Error:@} package @{%s@} is not found %s\n\ It's the basic, required package. If you have it installed globally,\n\ - Please run `npm link bs-platform` to make it available" in_json + Please run `npm link bs-platform` to make it available" name in_json else Format.fprintf fmt "File \"bsconfig.json\", line 1\n\ @@ -11054,7 +11054,7 @@ end = struct (* let get_list_string = Bsb_build_util.get_list_string *) let (//) = Ext_path.combine -let current_package : Bsb_pkg_types.t = Global Bs_version.package_name + let resolve_package cwd package_name = let x = Bsb_pkg.resolve_bs_package ~cwd package_name in { @@ -11142,6 +11142,7 @@ let check_stdlib (map : json_map) cwd (*built_in_package*) = | None | Some _ -> begin + let current_package : Bsb_pkg_types.t = Global !Bs_version.package_name in if Sys.getenv_opt "RES_SKIP_STDLIB_CHECK" = None then begin let stdlib_path = Bsb_pkg.resolve_bs_package ~cwd current_package in diff --git a/lib/4.06.1/unstable/js_compiler.ml b/lib/4.06.1/unstable/js_compiler.ml index 2ba982e65b..730c8a208f 100644 --- a/lib/4.06.1/unstable/js_compiler.ml +++ b/lib/4.06.1/unstable/js_compiler.ml @@ -18090,7 +18090,7 @@ val version : string val header : string -val package_name : string +val package_name : string ref end = struct #1 "bs_version.ml" @@ -18117,10 +18117,10 @@ end = struct * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let version = "8.4.0" +let version = "8.5.0" let header = "// Generated by ReScript, PLEASE EDIT WITH CARE" -let package_name = "bs-platform" +let package_name = ref "bs-platform" end module Bsc_warnings @@ -92118,6 +92118,9 @@ type package_info = { type t val runtime_package_specs : t + +val runtime_test_package_specs : t + val is_runtime_package: t -> bool @@ -92239,7 +92242,7 @@ type package_name = -let runtime_package_name = "bs-platform" + let (//) = Filename.concat @@ -92253,7 +92256,7 @@ let runtime_dir_of_module_system (ms : module_system ) = let runtime_package_path (ms : module_system) js_file = - runtime_package_name // "lib" // runtime_dir_of_module_system ms // js_file + !Bs_version.package_name // "lib" // runtime_dir_of_module_system ms // js_file type t = @@ -92269,6 +92272,14 @@ let runtime_package_specs : t = { {module_system = NodeJS; path = "lib/js"; suffix = Js}; ] } + +(** + populated by the command line +*) +let runtime_test_package_specs : t = { + name = Pkg_runtime; + module_systems = [] +} let same_package_by_name (x : t) (y : t) = x.name = y.name let is_runtime_package (x : t) = @@ -92295,16 +92306,10 @@ let empty : t = module_systems = [] } -let from_name (name : string) = - if name = runtime_package_name then - { - name = Pkg_runtime ; module_systems = [] - } - else - { - name = Pkg_normal name ; - module_systems = [] - } +let from_name (name : string) : t = { + name = Pkg_normal name ; + module_systems = [] +} let is_empty (x : t) = x.name = Pkg_empty @@ -92339,7 +92344,7 @@ let dump_package_name fmt (x : package_name) = match x with | Pkg_empty -> Format.fprintf fmt "@empty_pkg@" | Pkg_normal s -> Format.pp_print_string fmt s - | Pkg_runtime -> Format.pp_print_string fmt runtime_package_name + | Pkg_runtime -> Format.pp_print_string fmt "@runtime" let dump_packages_info (fmt : Format.formatter) @@ -92391,7 +92396,7 @@ let query_package_infos compatible k.module_system module_system) with | Some k -> let rel_path = k.path in - let pkg_rel_path = runtime_package_name // rel_path in + let pkg_rel_path = !Bs_version.package_name // rel_path in Package_found { rel_path ; @@ -92404,7 +92409,8 @@ let query_package_infos let get_js_path (x : t ) - module_system + (module_system : module_system) + : string = match Ext_list.find_first x.module_systems (fun k -> compatible k.module_system module_system) with @@ -92499,6 +92505,11 @@ module Js_packages_state : sig val set_package_name : string -> unit +val make_runtime: + unit -> unit + +val make_runtime_test: + unit -> unit val set_package_map : string -> unit val get_packages_info : @@ -92543,6 +92554,11 @@ let set_package_name name = else Bsc_args.bad_arg "duplicated flag for -bs-package-name" +let make_runtime () : unit = + packages_info := Js_packages_info.runtime_package_specs + +let make_runtime_test () : unit = + packages_info := Js_packages_info.runtime_test_package_specs let set_package_map module_name = (* set_package_name name ; let module_name = Ext_namespace.namespace_of_package_name name in *) @@ -98591,6 +98607,7 @@ let fix_path_for_windows : string -> string = else fun s -> s +(* dependency is runtime module *) let get_runtime_module_path (dep_module_id : Lam_module_ident.t) (current_package_info : Js_packages_info.t) diff --git a/lib/4.06.1/unstable/js_refmt_compiler.ml b/lib/4.06.1/unstable/js_refmt_compiler.ml index 460aa368ab..5d7c1e908d 100644 --- a/lib/4.06.1/unstable/js_refmt_compiler.ml +++ b/lib/4.06.1/unstable/js_refmt_compiler.ml @@ -18090,7 +18090,7 @@ val version : string val header : string -val package_name : string +val package_name : string ref end = struct #1 "bs_version.ml" @@ -18117,10 +18117,10 @@ end = struct * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let version = "8.4.0" +let version = "8.5.0" let header = "// Generated by ReScript, PLEASE EDIT WITH CARE" -let package_name = "bs-platform" +let package_name = ref "bs-platform" end module Bsc_warnings @@ -92118,6 +92118,9 @@ type package_info = { type t val runtime_package_specs : t + +val runtime_test_package_specs : t + val is_runtime_package: t -> bool @@ -92239,7 +92242,7 @@ type package_name = -let runtime_package_name = "bs-platform" + let (//) = Filename.concat @@ -92253,7 +92256,7 @@ let runtime_dir_of_module_system (ms : module_system ) = let runtime_package_path (ms : module_system) js_file = - runtime_package_name // "lib" // runtime_dir_of_module_system ms // js_file + !Bs_version.package_name // "lib" // runtime_dir_of_module_system ms // js_file type t = @@ -92269,6 +92272,14 @@ let runtime_package_specs : t = { {module_system = NodeJS; path = "lib/js"; suffix = Js}; ] } + +(** + populated by the command line +*) +let runtime_test_package_specs : t = { + name = Pkg_runtime; + module_systems = [] +} let same_package_by_name (x : t) (y : t) = x.name = y.name let is_runtime_package (x : t) = @@ -92295,16 +92306,10 @@ let empty : t = module_systems = [] } -let from_name (name : string) = - if name = runtime_package_name then - { - name = Pkg_runtime ; module_systems = [] - } - else - { - name = Pkg_normal name ; - module_systems = [] - } +let from_name (name : string) : t = { + name = Pkg_normal name ; + module_systems = [] +} let is_empty (x : t) = x.name = Pkg_empty @@ -92339,7 +92344,7 @@ let dump_package_name fmt (x : package_name) = match x with | Pkg_empty -> Format.fprintf fmt "@empty_pkg@" | Pkg_normal s -> Format.pp_print_string fmt s - | Pkg_runtime -> Format.pp_print_string fmt runtime_package_name + | Pkg_runtime -> Format.pp_print_string fmt "@runtime" let dump_packages_info (fmt : Format.formatter) @@ -92391,7 +92396,7 @@ let query_package_infos compatible k.module_system module_system) with | Some k -> let rel_path = k.path in - let pkg_rel_path = runtime_package_name // rel_path in + let pkg_rel_path = !Bs_version.package_name // rel_path in Package_found { rel_path ; @@ -92404,7 +92409,8 @@ let query_package_infos let get_js_path (x : t ) - module_system + (module_system : module_system) + : string = match Ext_list.find_first x.module_systems (fun k -> compatible k.module_system module_system) with @@ -92499,6 +92505,11 @@ module Js_packages_state : sig val set_package_name : string -> unit +val make_runtime: + unit -> unit + +val make_runtime_test: + unit -> unit val set_package_map : string -> unit val get_packages_info : @@ -92543,6 +92554,11 @@ let set_package_name name = else Bsc_args.bad_arg "duplicated flag for -bs-package-name" +let make_runtime () : unit = + packages_info := Js_packages_info.runtime_package_specs + +let make_runtime_test () : unit = + packages_info := Js_packages_info.runtime_test_package_specs let set_package_map module_name = (* set_package_name name ; let module_name = Ext_namespace.namespace_of_package_name name in *) @@ -98591,6 +98607,7 @@ let fix_path_for_windows : string -> string = else fun s -> s +(* dependency is runtime module *) let get_runtime_module_path (dep_module_id : Lam_module_ident.t) (current_package_info : Js_packages_info.t) diff --git a/lib/4.06.1/whole_compiler.ml b/lib/4.06.1/whole_compiler.ml index f12dad3e2a..48d268230a 100644 --- a/lib/4.06.1/whole_compiler.ml +++ b/lib/4.06.1/whole_compiler.ml @@ -304574,7 +304574,7 @@ val version : string val header : string -val package_name : string +val package_name : string ref end = struct #1 "bs_version.ml" @@ -304601,10 +304601,10 @@ end = struct * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let version = "8.4.0" +let version = "8.5.0" let header = "// Generated by ReScript, PLEASE EDIT WITH CARE" -let package_name = "bs-platform" +let package_name = ref "bs-platform" end module Bsc_warnings @@ -370433,6 +370433,9 @@ type package_info = { type t val runtime_package_specs : t + +val runtime_test_package_specs : t + val is_runtime_package: t -> bool @@ -370554,7 +370557,7 @@ type package_name = -let runtime_package_name = "bs-platform" + let (//) = Filename.concat @@ -370568,7 +370571,7 @@ let runtime_dir_of_module_system (ms : module_system ) = let runtime_package_path (ms : module_system) js_file = - runtime_package_name // "lib" // runtime_dir_of_module_system ms // js_file + !Bs_version.package_name // "lib" // runtime_dir_of_module_system ms // js_file type t = @@ -370584,6 +370587,14 @@ let runtime_package_specs : t = { {module_system = NodeJS; path = "lib/js"; suffix = Js}; ] } + +(** + populated by the command line +*) +let runtime_test_package_specs : t = { + name = Pkg_runtime; + module_systems = [] +} let same_package_by_name (x : t) (y : t) = x.name = y.name let is_runtime_package (x : t) = @@ -370610,16 +370621,10 @@ let empty : t = module_systems = [] } -let from_name (name : string) = - if name = runtime_package_name then - { - name = Pkg_runtime ; module_systems = [] - } - else - { - name = Pkg_normal name ; - module_systems = [] - } +let from_name (name : string) : t = { + name = Pkg_normal name ; + module_systems = [] +} let is_empty (x : t) = x.name = Pkg_empty @@ -370654,7 +370659,7 @@ let dump_package_name fmt (x : package_name) = match x with | Pkg_empty -> Format.fprintf fmt "@empty_pkg@" | Pkg_normal s -> Format.pp_print_string fmt s - | Pkg_runtime -> Format.pp_print_string fmt runtime_package_name + | Pkg_runtime -> Format.pp_print_string fmt "@runtime" let dump_packages_info (fmt : Format.formatter) @@ -370706,7 +370711,7 @@ let query_package_infos compatible k.module_system module_system) with | Some k -> let rel_path = k.path in - let pkg_rel_path = runtime_package_name // rel_path in + let pkg_rel_path = !Bs_version.package_name // rel_path in Package_found { rel_path ; @@ -370719,7 +370724,8 @@ let query_package_infos let get_js_path (x : t ) - module_system + (module_system : module_system) + : string = match Ext_list.find_first x.module_systems (fun k -> compatible k.module_system module_system) with @@ -381040,6 +381046,11 @@ module Js_packages_state : sig val set_package_name : string -> unit +val make_runtime: + unit -> unit + +val make_runtime_test: + unit -> unit val set_package_map : string -> unit val get_packages_info : @@ -381084,6 +381095,11 @@ let set_package_name name = else Bsc_args.bad_arg "duplicated flag for -bs-package-name" +let make_runtime () : unit = + packages_info := Js_packages_info.runtime_package_specs + +let make_runtime_test () : unit = + packages_info := Js_packages_info.runtime_test_package_specs let set_package_map module_name = (* set_package_name name ; let module_name = Ext_namespace.namespace_of_package_name name in *) @@ -381176,6 +381192,7 @@ let fix_path_for_windows : string -> string = else fun s -> s +(* dependency is runtime module *) let get_runtime_module_path (dep_module_id : Lam_module_ident.t) (current_package_info : Js_packages_info.t) @@ -436307,7 +436324,11 @@ let buckle_script_flags : (string * Bsc_args.spec * string) array = " Enable or disable error status for warnings according\n\ to . See option -w for the syntax of .\n\ Default setting is " ^ Bsc_warnings.defaults_warn_error; - + "-make-runtime", unit_call Js_packages_state.make_runtime, + "*internal* make runtime library"; + "-make-runtime-test", unit_call Js_packages_state.make_runtime_test, + "*internal* make runtime test library"; + |] diff --git a/package.json b/package.json index 8c1c02fd2d..8b18b665a7 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "coverage": "nyc --timeout=3000 --reporter=html mocha jscomp/test/*test.js && open ./coverage/index.html" }, "name": "bs-platform", - "version": "8.4.0", + "version": "8.5.0", "description": "ReScript compiler, OCaml standard libary by ReScript and its required runtime support", "repository": { "type": "git", diff --git a/scripts/ninja.js b/scripts/ninja.js index eab0d693e3..c99a1cece3 100755 --- a/scripts/ninja.js +++ b/scripts/ninja.js @@ -836,7 +836,7 @@ async function runtimeNinja(devmode = true) { var externalDeps = devmode ? [compilerTarget] : []; var ninjaOutput = devmode ? "build.ninja" : "release.ninja"; var templateRuntimeRules = ` -bsc_no_open_flags = ${commonBsFlags} -bs-cross-module-opt -bs-package-name bs-platform -bs-package-output commonjs:lib/js -bs-package-output es6:lib/es6:.mjs -nopervasives -unsafe -w +50 -warn-error A +bsc_no_open_flags = ${commonBsFlags} -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A bsc_flags = $bsc_no_open_flags -open Bs_stdlib_mini ${ruleCC(ninjaCwd)} ${ninjaQuickBuidList([ @@ -931,7 +931,7 @@ async function othersNinja(devmode = true) { var ninjaCwd = "others"; var templateOthersRules = ` -bsc_flags = ${commonBsFlags} -bs-cross-module-opt -bs-package-name bs-platform -bs-package-output commonjs:lib/js -bs-package-output es6:lib/es6:.mjs -nopervasives -unsafe -w +50 -warn-error A -open Bs_stdlib_mini -I ./runtime +bsc_flags = ${commonBsFlags} -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A -open Bs_stdlib_mini -I ./runtime ${ruleCC(ninjaCwd)} ${ devmode @@ -1056,7 +1056,7 @@ async function stdlibNinja(devmode = true) { // deprecations diabled due to string_of_float var warnings = "-w -9-3-106 -warn-error A"; var templateStdlibRules = ` -${bsc_flags} = ${commonBsFlags} -bs-cross-module-opt -bs-package-name bs-platform -bs-package-output commonjs:lib/js -bs-package-output es6:lib/es6:.mjs ${warnings} -I runtime -I others +${bsc_flags} = ${commonBsFlags} -bs-cross-module-opt -make-runtime ${warnings} -I runtime -I others ${ruleCC(ninjaCwd)} ${ninjaQuickBuidList([ [ @@ -1190,7 +1190,7 @@ async function testNinja() { var ninjaOutput = "build.ninja"; var ninjaCwd = `test`; var templateTestRules = ` -bsc_flags = -bs-no-version-header -bs-cross-module-opt -bs-package-name bs-platform -bs-package-output commonjs:jscomp/test -w -3-6-26-27-29-30-32..40-44-45-52-60-9-106+104 -warn-error A -I runtime -I $stdlib -I others +bsc_flags = -bs-no-version-header -bs-cross-module-opt -make-runtime-test -bs-package-output commonjs:jscomp/test -w -3-6-26-27-29-30-32..40-44-45-52-60-9-106+104 -warn-error A -I runtime -I $stdlib -I others ${ruleCC(ninjaCwd)}