From a9a54fd2dc1cd3e09a2b051871f43edf6d882cb6 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Fri, 6 Nov 2026 13:35:32 +0000 Subject: [PATCH 1/3] Write each package's build artifacts flat to lib/rescript MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why: Every artifact existed in lib/bs, nested like the sources, and again in lib/ocaml, flat, and lib/bs also held copies of the sources and the generated JavaScript (#9151). The build now writes one flat lib/rescript. Layout modified (artifact directory of a package): Before (text): lib/bs/src/A.ast lib/bs/src/A.cmi lib/bs/src/A.res lib/bs/src/A.js lib/bs/.compiler.log lib/bs/compiler-info.json lib/bs/.sourcedirs.json lib/bs/build.ninja lib/ocaml/A.ast lib/ocaml/A.cmi lib/ocaml/A.cmj lib/ocaml/A.cmt lib/ocaml/A.res lib/build.lock lib/watch.lock After (text): lib/rescript/A.ast lib/rescript/A.cmi lib/rescript/A.cmj lib/rescript/A.cmt lib/rescript/.compiler.log lib/rescript/compiler-info.json lib/rescript/.sourcedirs.json lib/rescript/build.lock lib/rescript/watch.lock Before (text): bsc runs in lib/bs with -I ../ocaml; the stdlib is /lib/ocaml After (text): bsc runs in lib/rescript with -I .; the stdlib is /lib/rescript Publication modified (a compiled module's ASTs, interface and typed tree): Before (text): written to lib/bs by bsc, then copied to lib/ocaml After (text): held in the build file store until the request succeeded, then 1. the interface, only when it changed 2. the typed tree, which marks the module compiled each renamed into place, or written in place when the rename fails a failed compile: interface forgotten, AST dated back, partial typed tree published Freshness modified (Build_freshness, Compiler_info, namespace maps): Before (representation): source removed or must be parsed again ↦ AST removed no compiler-info.json, lib/ocaml/.compiler.log exists ↦ clean Ns.mlmap changed or Ns outputs missing ↦ compile namespace After (representation): source must be parsed again ↦ AST dated back to time 1, always parsed again compiler-info.json written once the clean decision is made compile namespace ↦ Ns.cmt removed until the compile publishes it lib/bs or lib/ocaml exists ↦ clean, which removes them The compiler keeps early cutoff with one copy of each interface: it replaces an interface it cannot read instead of failing, and a .cmj cut short after its digest no longer counts as unchanged. Stale public JavaScript is removed when an AST proves the build generated it; the JS mirror and the build.ninja marker are gone. Clean empties lib/rescript but for the lock files. Review: Why hold ASTs as well as interfaces? A failed parse used to leave its AST in lib/bs only; with one copy it would look current and the next build would skip the parse and lose the error. Review: Why rename into place, with an in-place write only as a fallback? A build killed during an in-place write leaves a truncated file, and a truncated typed tree with a fresh time counts as compiled for good. On Windows the rename fails while an editor has the file open without delete sharing, so the file is then written in place. Review: Why date an AST back instead of removing it? A later compile of the same build or watch session may still read it. Time 1 is below any real source time except the epoch, which is why such an AST is always parsed again. Review: What about a removed module's working .cmi, which cleanup deferred? It went to lib/bs, outside the include path. In lib/rescript it would let dependents compile against a deleted module, so it is removed at once. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Kbf3gGBR9g3DD93vrWbYzU Signed-off-by: Christoph Knittel --- compiler/core/bs_cmi_load.ml | 16 +- compiler/core/js_cmj_format.ml | 25 +- compiler/core/js_cmj_format.mli | 4 +- compiler/core/js_cmj_load.ml | 8 +- compiler/core/lam_compile_env.ml | 6 +- compiler/core/lam_compile_env.mli | 4 +- .../platform/native/js_name_of_module_id.ml | 4 +- compiler/core/res_compmisc.ml | 2 +- compiler/ext/build_file_store.ml | 80 ++- compiler/ext/build_file_store.mli | 21 +- compiler/ml/cmi_format.ml | 10 +- compiler/ml/cmt_format_common.ml | 42 +- compiler/ml/env.ml | 6 +- rewatch-ocaml/README.md | 34 +- rewatch-ocaml/ast_header.ml | 6 +- rewatch-ocaml/build.ml | 40 +- rewatch-ocaml/build_artifacts.ml | 262 ++----- rewatch-ocaml/build_artifacts.mli | 28 +- rewatch-ocaml/build_attempt.ml | 11 +- rewatch-ocaml/build_attempt.mli | 1 - rewatch-ocaml/build_freshness.ml | 17 +- rewatch-ocaml/build_lock.ml | 3 +- rewatch-ocaml/build_preparation.ml | 53 +- rewatch-ocaml/build_session.ml | 10 - rewatch-ocaml/build_session.mli | 1 - rewatch-ocaml/clean.ml | 4 +- rewatch-ocaml/compile_assets.ml | 8 +- rewatch-ocaml/compile_assets.mli | 5 +- rewatch-ocaml/compiler_args.ml | 4 +- rewatch-ocaml/compiler_args_command.ml | 2 +- rewatch-ocaml/compiler_info.ml | 23 +- rewatch-ocaml/compiler_log.ml | 12 +- rewatch-ocaml/compiler_process.ml | 258 ++++--- rewatch-ocaml/compiler_process.mli | 32 +- rewatch-ocaml/compiler_scheduler.ml | 6 +- rewatch-ocaml/file_util.ml | 133 +--- rewatch-ocaml/file_util.mli | 25 +- rewatch-ocaml/module_graph.ml | 6 +- rewatch-ocaml/module_graph.mli | 4 +- rewatch-ocaml/native_watcher.ml | 2 +- rewatch-ocaml/package_build.ml | 3 +- rewatch-ocaml/package_compilation.ml | 39 +- rewatch-ocaml/package_graph.ml | 6 +- rewatch-ocaml/package_parse.ml | 30 +- rewatch-ocaml/package_plan.ml | 3 +- rewatch-ocaml/package_plan.mli | 3 +- rewatch-ocaml/source.ml | 4 +- rewatch-ocaml/source.mli | 3 + rewatch-ocaml/source_dirs.ml | 38 +- .../tests/check_command_validation.sh | 46 +- .../tests/check_config_acceptance.sh | 2 +- .../tests/check_interactive_output.sh | 4 +- rewatch-ocaml/tests/run.sh | 165 +++-- .../snapshots/config_acceptance/arguments.txt | 672 +++++++++--------- rewatch/MonorepoSupport.md | 22 +- rewatch/tests/clean/03-clean-node-modules.sh | 4 +- rewatch/tests/gentype/project-root.mjs | 4 +- rewatch/tests/lock/01-lock-when-watching.sh | 10 +- rewatch/tests/snapshots/dependency-cycle.txt | 2 +- .../dev-dependency-used-by-non-dev-source.txt | 2 +- rewatch/tests/snapshots/remove-file.txt | 2 +- .../rename-file-internal-dep-namespace.txt | 2 +- .../snapshots/rename-file-internal-dep.txt | 2 +- .../snapshots/rename-file-with-interface.txt | 2 +- rewatch/tests/snapshots/rename-file.txt | 2 +- .../tests/snapshots/rename-interface-file.txt | 2 +- rewatch/tests/suffix/01-custom-suffix.sh | 2 +- rewatch/tests/utils.sh | 12 +- .../02-watch-warnings-persist-atomic-save.sh | 2 +- rewatch/tests/watch/04-watch-config-change.sh | 2 +- ...d-interface-after-failed-implementation.sh | 6 +- .../09-watch-recovers-from-invalid-config.sh | 4 +- .../ounit_build_file_store_tests.ml | 130 ++++ .../ounit_compiler_request_tests.ml | 4 +- .../build_artifacts_tests.ml | 345 ++++----- .../build_attempt_tests.ml | 4 +- tests/rewatch_ounit_tests/build_file_tests.ml | 49 +- tests/rewatch_ounit_tests/clean_tests.ml | 8 +- .../compiler_args_tests.ml | 7 +- .../compiler_info_tests.ml | 40 +- .../compiler_process_tests.ml | 380 ++++++---- .../compiler_scheduler_tests.ml | 31 +- tests/rewatch_ounit_tests/config_tests.ml | 10 +- tests/rewatch_ounit_tests/file_util_tests.ml | 130 +--- .../native_watcher_tests.ml | 8 +- tests/rewatch_ounit_tests/test_support.ml | 4 + tests/rewatch_ounit_tests/unit_tests.ml | 20 +- tests/rewatch_ounit_tests/watcher_tests.ml | 2 +- 88 files changed, 1729 insertions(+), 1763 deletions(-) diff --git a/compiler/core/bs_cmi_load.ml b/compiler/core/bs_cmi_load.ml index 2c197e2832a..f0d8629df98 100644 --- a/compiler/core/bs_cmi_load.ml +++ b/compiler/core/bs_cmi_load.ml @@ -30,11 +30,17 @@ let read_file path = match Unix.openfile path [Unix.O_RDONLY; Unix.O_CLOEXEC; Unix.O_SHARE_DELETE] 0 with - | descriptor -> - let channel = Unix.in_channel_of_descr descriptor in - Fun.protect - ~finally:(fun () -> close_in_noerr channel) - (fun () -> Some (really_input_string channel (in_channel_length channel))) + | descriptor -> ( + (* A directory opens, and fails only here. *) + match Unix.in_channel_of_descr descriptor with + | exception Unix.Unix_error (error, _, _) -> + Unix.close descriptor; + raise (Sys_error (path ^ ": " ^ Unix.error_message error)) + | channel -> + Fun.protect + ~finally:(fun () -> close_in_noerr channel) + (fun () -> + Some (really_input_string channel (in_channel_length channel)))) | exception Unix.Unix_error ((Unix.ENOENT | Unix.ENOTDIR), _, _) -> None | exception Unix.Unix_error (error, _, _) -> raise (Sys_error (path ^ ": " ^ Unix.error_message error)) diff --git a/compiler/core/js_cmj_format.ml b/compiler/core/js_cmj_format.ml index ca647075df5..b31bb916d70 100644 --- a/compiler/core/js_cmj_format.ml +++ b/compiler/core/js_cmj_format.ml @@ -72,10 +72,12 @@ let make ~(values : cmj_value Map_string.t) ~effect_ ~package_spec ~case : t = let from_file name : t = Ext_io.unmarshal (Ext_io.load_file name) Ext_digest.length -let for_sure_not_changed (name : string) (header : string) = +(* The length rules out a file cut short after its digest, as by a build + killed while it wrote it in place. *) +let for_sure_not_changed (name : string) (header : string) ~length = match Build_file_store.read (Compiler_request_state.resolve_path name) with | Some contents -> - String.length contents >= Ext_digest.length + String.length contents = length && String.sub contents 0 Ext_digest.length = header | None -> false @@ -86,7 +88,12 @@ let to_file name ~check_exists (v : t) = let s = Marshal.to_string v [] in let cur_digest = Digest.string s in let header = cur_digest in - if not (check_exists && for_sure_not_changed name header) then + if + not + (check_exists + && for_sure_not_changed name header + ~length:(String.length header + String.length s)) + then Build_file_store.write (Compiler_request_state.resolve_path name) (header ^ s) @@ -145,14 +152,4 @@ let query_by_name (cmj_table : t) name : keyed_cmj_value = let values = cmj_table.values in binary_search values name -type path = string - -type cmj_load_info = { - cmj_table: t; - package_path: path; - (* - Note it is the package path we want - for ES6_global module spec - Maybe we can employ package map in the future - *) -} +type cmj_load_info = {cmj_table: t} diff --git a/compiler/core/js_cmj_format.mli b/compiler/core/js_cmj_format.mli index 937f5257778..c6a8d17bd1b 100644 --- a/compiler/core/js_cmj_format.mli +++ b/compiler/core/js_cmj_format.mli @@ -86,6 +86,4 @@ val from_file : string -> t *) val to_file : string -> check_exists:bool -> t -> unit -type path = string - -type cmj_load_info = {cmj_table: t; package_path: path} +type cmj_load_info = {cmj_table: t} diff --git a/compiler/core/js_cmj_load.ml b/compiler/core/js_cmj_load.ml index 7fbfec7793b..4eb8c7f143c 100644 --- a/compiler/core/js_cmj_load.ml +++ b/compiler/core/js_cmj_load.ml @@ -30,11 +30,5 @@ let load_unit unit_name : Js_cmj_format.cmj_load_info = let file = unit_name ^ Literals.suffix_cmj in match Config_util.find_opt file with - | Some f -> - { - package_path = - (* hacking relying on the convention of pkg/lib/ocaml/xx.cmj*) - Filename.dirname (Filename.dirname (Filename.dirname f)); - cmj_table = Js_cmj_format.from_file f; - } + | Some f -> {cmj_table = Js_cmj_format.from_file f} | None -> Bs_exception.error (Cmj_not_found unit_name) diff --git a/compiler/core/lam_compile_env.ml b/compiler/core/lam_compile_env.ml index b67e68c38f8..b7df1384060 100644 --- a/compiler/core/lam_compile_env.ml +++ b/compiler/core/lam_compile_env.ml @@ -106,8 +106,8 @@ let query_external_id_info ?(dynamic_import = false) (module_id : Ident.t) let cmj_table = cmj_table_of_module_id ~dynamic_import module_id in Js_cmj_format.query_by_name cmj_table name -let get_package_path_from_cmj (id : Lam_module_ident.t) : - string * Js_packages_info.t * Ext_js_file_kind.case = +let get_package_info_from_cmj (id : Lam_module_ident.t) : + Js_packages_info.t * Ext_js_file_kind.case = let cmj_load_info = match Lam_module_ident.Hash.find_opt (cached_tbl ()) id with | Some (Ml cmj_load_info) -> cmj_load_info @@ -124,7 +124,7 @@ let get_package_path_from_cmj (id : Lam_module_ident.t) : cmj_load_info) in let cmj_table = cmj_load_info.cmj_table in - (cmj_load_info.package_path, cmj_table.package_spec, cmj_table.case) + (cmj_table.package_spec, cmj_table.case) let add = Lam_module_ident.set_add diff --git a/compiler/core/lam_compile_env.mli b/compiler/core/lam_compile_env.mli index 5ee697dc442..02d7e92932c 100644 --- a/compiler/core/lam_compile_env.mli +++ b/compiler/core/lam_compile_env.mli @@ -77,8 +77,8 @@ val query_external_id_info : val is_pure_module : Lam_module_ident.t -> bool -val get_package_path_from_cmj : - Lam_module_ident.t -> string * Js_packages_info.t * Ext_js_file_kind.case +val get_package_info_from_cmj : + Lam_module_ident.t -> Js_packages_info.t * Ext_js_file_kind.case (* The second argument is mostly from [runtime] modules will change the input [hard_dependencies] diff --git a/compiler/core/platform/native/js_name_of_module_id.ml b/compiler/core/platform/native/js_name_of_module_id.ml index f45da2cde39..8165a5d240a 100644 --- a/compiler/core/platform/native/js_name_of_module_id.ml +++ b/compiler/core/platform/native/js_name_of_module_id.ml @@ -86,8 +86,8 @@ let string_of_module_id (dep_module_id : Lam_module_ident.t) let current_info_query = Js_packages_info.query_package_infos current_package_info module_system in - match Lam_compile_env.get_package_path_from_cmj dep_module_id with - | _, dep_package_info, case -> ( + match Lam_compile_env.get_package_info_from_cmj dep_module_id with + | dep_package_info, case -> ( let dep_info_query = Js_packages_info.query_package_infos dep_package_info module_system in diff --git a/compiler/core/res_compmisc.ml b/compiler/core/res_compmisc.ml index 7f117a2ad26..4818c1bfa72 100644 --- a/compiler/core/res_compmisc.ml +++ b/compiler/core/res_compmisc.ml @@ -25,7 +25,7 @@ let init_path () = let stdlib_dir = let ( // ) = Filename.concat in - Runtime_package.get_path () // "lib" // "ocaml" + Runtime_package.get_path () // "lib" // "rescript" in let dirs = !((Clflags.current ()).include_dirs) in let exp_dirs = List.map (Misc.expand_directory stdlib_dir) dirs in diff --git a/compiler/ext/build_file_store.ml b/compiler/ext/build_file_store.ml index f1374eb611e..49bee51108c 100644 --- a/compiler/ext/build_file_store.ml +++ b/compiler/ext/build_file_store.ml @@ -9,10 +9,15 @@ So an entry changes only when it is written through the store, and the store is emptied before each build. *) +(* What the disk holds for a path, as far as the build has read it. *) +type on_disk = Read of string | Missing | Unknown + type entry = | Contents of string | Exists (** On disk, contents not read yet. *) | Absent + | Held of {contents: string; on_disk: on_disk} + (** Written by a request, not on disk until {!publish_held}. *) (* [enabled] and [generation] are read without the lock: only [with_build] changes them, before a build's requests start and after they finish. *) @@ -53,6 +58,9 @@ let default_disk_reader path = let disk_reader = Atomic.make default_disk_reader let set_disk_reader reader = Atomic.set disk_reader reader +let held_writes = Atomic.make (fun (_ : string) -> false) +let set_held_writes held = Atomic.set held_writes held + let enabled () = state.enabled let generation () = state.generation @@ -70,9 +78,10 @@ let with_build f = empty ())) (* Requests spell paths relative to their own working directory, such as - [lib/bs/../ocaml/A.cmi], and the build system as [lib/ocaml/A.cmi]. Both - must find the same entry. Build directories are never symbolic links, so - removing [..] lexically is sound for the paths the store sees. *) + [lib/rescript/./A.cmi] or [lib/rescript/../../src/A.res], and the build + system as [lib/rescript/A.cmi]. Both must find the same entry. Build + directories are never symbolic links, so removing [..] lexically is sound + for the paths the store sees. *) let key path = let is_separator c = c = '/' || (Sys.win32 && c = '\\') in let length = String.length path in @@ -104,18 +113,18 @@ let record key entry = locked (fun () -> if state.enabled then Hashtbl.replace state.entries key entry) -let read path = +let read ?(keep = true) path = if not state.enabled then (Atomic.get disk_reader) path else let key = key path in match find key with - | Some (Contents contents) -> Some contents + | Some (Contents contents | Held {contents; _}) -> Some contents | Some Absent -> None | Some Exists | None -> let contents = (Atomic.get disk_reader) path in record key (match contents with - | Some contents -> Contents contents + | Some contents -> if keep then Contents contents else Exists | None -> Absent); contents @@ -124,7 +133,7 @@ let exists path = else let key = key path in match find key with - | Some (Contents _ | Exists) -> true + | Some (Contents _ | Exists | Held _) -> true | Some Absent -> false | None -> let exists = Sys.file_exists path in @@ -140,15 +149,29 @@ let write_to_disk path contents = close_out channel) let write ?(keep = true) path contents = - match write_to_disk path contents with - | () -> - if state.enabled then - record (key path) (if keep then Contents contents else Exists) - | exception exn -> - (* A failed write can leave anything on disk. *) - if state.enabled then - locked (fun () -> Hashtbl.remove state.entries (key path)); - raise exn + if state.enabled && (Atomic.get held_writes) path then + let key = key path in + locked (fun () -> + (* Remember what the disk holds, so that publishing compares with + what this build read instead of reading it again. *) + let on_disk = + match Hashtbl.find_opt state.entries key with + | Some (Contents contents) -> Read contents + | Some Absent -> Missing + | Some (Held {on_disk; _}) -> on_disk + | Some Exists | None -> Unknown + in + Hashtbl.replace state.entries key (Held {contents; on_disk})) + else + match write_to_disk path contents with + | () -> + if state.enabled then + record (key path) (if keep then Contents contents else Exists) + | exception exn -> + (* A failed write can leave anything on disk. *) + if state.enabled then + locked (fun () -> Hashtbl.remove state.entries (key path)); + raise exn let evict path = if state.enabled then @@ -156,7 +179,8 @@ let evict path = locked (fun () -> match Hashtbl.find_opt state.entries key with | Some (Contents _) -> Hashtbl.replace state.entries key Exists - | Some (Exists | Absent) | None -> ()) + (* Held contents exist nowhere else. *) + | Some (Exists | Absent | Held _) | None -> ()) let forget path = if state.enabled then @@ -166,5 +190,25 @@ let cached path = if not state.enabled then None else match find (key path) with - | Some (Contents contents) -> Some contents + | Some (Contents contents | Held {contents; _}) -> Some contents | Some (Exists | Absent) | None -> None + +let publish_held ~if_changed ~write path = + let key = key path in + match find key with + | Some (Held {contents; on_disk}) -> + let changed = + (not if_changed) + || + let on_disk = + match on_disk with + | Read on_disk -> Some on_disk + | Missing -> None + | Unknown -> (Atomic.get disk_reader) path + in + on_disk <> Some contents + in + if changed then write path contents; + record key (Contents contents); + changed + | Some (Contents _ | Exists | Absent) | None -> raise Not_found diff --git a/compiler/ext/build_file_store.mli b/compiler/ext/build_file_store.mli index 583f51bcdb8..5072050af05 100644 --- a/compiler/ext/build_file_store.mli +++ b/compiler/ext/build_file_store.mli @@ -22,9 +22,11 @@ val generation : unit -> int (** Changes whenever the store is emptied, so caches derived from its contents know to start over. *) -val read : string -> string option +val read : ?keep:bool -> string -> string option (** [read path] is the contents of [path], or [None] when it does not exist. - Other failures raise [Sys_error]. *) + Other failures raise [Sys_error]. Contents read from disk are kept for + later reads unless [keep] is [false], which suits large files that one + request reads, such as typed trees. *) val exists : string -> bool @@ -42,6 +44,21 @@ val set_disk_reader : (string -> string option) -> unit [open_in_bin]; a build system can install one that tells a missing file from an unreadable one more precisely. Install it before requests run. *) +val set_held_writes : (string -> bool) -> unit +(** While the store is enabled, writes to the paths the predicate selects are + held in memory instead of written to disk: reads see them, and + {!publish_held} or {!forget} ends them. A build system holds interfaces + this way, so that one is written to disk only after its compile succeeded, + and only when it changed. Install it before requests run. *) + +val publish_held : + if_changed:bool -> write:(string -> string -> unit) -> string -> bool +(** [publish_held ~if_changed ~write path] calls [write path contents] with the + held contents of [path], keeps them for later reads, and returns whether it + wrote them. With [if_changed], it writes them only when they differ from + the file on disk, so that an unchanged file keeps its modification time. + Raises [Not_found] when nothing is held for [path]. *) + val forget : string -> unit (** [forget path] drops everything known about [path]. Call it after changing [path] other than through {!write}. *) diff --git a/compiler/ml/cmi_format.ml b/compiler/ml/cmi_format.ml index e39b1176823..819fe3ea7e1 100644 --- a/compiler/ml/cmi_format.ml +++ b/compiler/ml/cmi_format.ml @@ -101,8 +101,14 @@ let create_cmi ?check_exists filename (cmi : cmi_infos) = let cmi_infos = if check_exists = None then None else - Build_file_store.read (Compiler_request_state.resolve_path filename) - |> Option.map (read_cmi_contents filename) + match + Build_file_store.read (Compiler_request_state.resolve_path filename) + with + | None -> None + | Some contents -> ( + (* An interface cut short, as by a build killed while it wrote it in + place, or one of another version, is replaced. *) + try Some (read_cmi_contents filename contents) with Error _ -> None) in match cmi_infos with | Some diff --git a/compiler/ml/cmt_format_common.ml b/compiler/ml/cmt_format_common.ml index 9a7b25a222a..c42455d58f0 100644 --- a/compiler/ml/cmt_format_common.ml +++ b/compiler/ml/cmt_format_common.ml @@ -58,10 +58,6 @@ type cmt_infos = { integrated in Typerex). *) -let read_magic_number ic = - let len_magic_number = String.length Config.cmt_magic_number in - really_input_string ic len_magic_number - type error = Not_a_typedtree of string let need_to_clear_env = @@ -100,27 +96,29 @@ let clear_env binary_annots = exception Error of error -let input_cmt ic = (input_value ic : cmt_infos) - (** [read filename] reads a .cmi file as its cmi_infos, or a .cmt or .cmti file as its cmt_infos. *) let read filename = - (* Printf.fprintf stderr "Cmt_format.read %s\n%!" filename; *) - let ic = open_in_bin (Compiler_request_state.resolve_path filename) in - try - let magic_number = read_magic_number ic in - let cmi, cmt = - if magic_number = Config.cmt_magic_number then (None, Some (input_cmt ic)) - else if magic_number = Config.cmi_magic_number then - (Some (Cmi_format.input_cmi ic), None) - else raise (Cmi_format.Error (Cmi_format.Not_an_interface filename)) - in - close_in ic; - (* Printf.fprintf stderr "Cmt_format.read done\n%!"; *) - (cmi, cmt) - with e -> - close_in ic; - raise e + (* Through the build file store, which holds the typed tree of the module + being compiled until the build publishes it, without keeping the typed + trees of other modules. *) + let path = Compiler_request_state.resolve_path filename in + let contents = + match Build_file_store.read ~keep:false path with + | Some contents -> contents + | None -> raise (Sys_error (path ^ ": No such file or directory")) + in + let magic_length = String.length Config.cmt_magic_number in + let magic_number = + if String.length contents < magic_length then + raise (Cmi_format.Error (Cmi_format.Not_an_interface filename)) + else String.sub contents 0 magic_length + in + if magic_number = Config.cmt_magic_number then + (None, Some (Marshal.from_string contents magic_length : cmt_infos)) + else if magic_number = Config.cmi_magic_number then + (Some (Cmi_format.read_cmi_contents filename contents), None) + else raise (Cmi_format.Error (Cmi_format.Not_an_interface filename)) let read_cmt filename = match read filename with diff --git a/compiler/ml/env.ml b/compiler/ml/env.ml index 34154bbac22..f40ba2dc63d 100644 --- a/compiler/ml/env.ml +++ b/compiler/ml/env.ml @@ -1891,7 +1891,11 @@ let save_signature_with_imports ?check_exists ~deprecated sg modname filename save_pers_struct crc ps; cmi with exn -> - remove_file filename; + (* A build holds the new interface until the request succeeded: dropping + it leaves the previous one on disk. *) + if Build_file_store.enabled () then + Build_file_store.forget (Compiler_request_state.resolve_path filename) + else remove_file filename; raise exn let save_signature ?check_exists ~deprecated sg modname filename = diff --git a/rewatch-ocaml/README.md b/rewatch-ocaml/README.md index 8e9ac867edb..e3f25b27eac 100644 --- a/rewatch-ocaml/README.md +++ b/rewatch-ocaml/README.md @@ -28,7 +28,7 @@ _build/default/rewatch-ocaml/rescript_ocaml.exe build path/to/project ``` Builds and `rescript format` use the embedded compiler. The `bsc.exe` next to -`rescript.exe` is still recorded in `lib/bs/compiler-info.json`, where editor +`rescript.exe` is still recorded in `lib/rescript/compiler-info.json`, where editor tooling looks for the platform binaries. Linux release builds use dune's `static` profile, so the published executable @@ -57,6 +57,38 @@ Native filesystem notifications only wake the watcher. The snapshot taken afterwards decides what changed, so merged, reordered, or dropped events can't cause missed rebuilds. +## Artifacts + +Each package keeps its artifacts flat in `lib/rescript`, keyed by the +compiler's file name of each module (`X` or `X-Ns`): ASTs, `.cmi`, `.cmj`, +`.cmt` and `.cmti` files, namespace maps, `.compiler.log`, +`compiler-info.json`, `.sourcedirs.json` and, in the project that takes them, +the build and watch locks. The compiler runs in that directory and writes +there directly; dependencies are on its include path as their +`lib/rescript`. + +- Freshness is timestamp-based: an AST newer than its source is current, a + `.cmt` records the last compile, and a `.cmi` the last change of an + interface. +- ASTs, interfaces and typed trees are held in memory until their request + finished (`Build_file_store.set_held_writes`), so a failed request leaves + the previous AST and interface on disk. An interface is written only when + it changed, which keeps the modification time that dependents compare + with, and before the typed tree that marks the module compiled, so a build + killed in between compiles the module again. A failed compile publishes its + partial typed tree for editor tooling after dating its AST back. +- Published files are renamed into place, so neither a reader nor a killed + build sees part of one. On Windows the rename fails while an editor has the + file open without delete sharing; the file is then written in place, and a + failed write removes its partial file. +- To make the next build parse a source again, the build dates its AST back + instead of removing it: a later compile of the same build or watch session + may still read it. +- Stale public JavaScript is removed only when an AST shows that the build + generated it for a source that is gone. +- `lib/bs` and `lib/ocaml`, left by ReScript 12 and earlier, make the first + build clean the package and are removed with it. + ## In-process compilation Independent parse and compile requests run on a bounded pool of OCaml domains. diff --git a/rewatch-ocaml/ast_header.ml b/rewatch-ocaml/ast_header.ml index 4c59b3f1229..21bf3a779bd 100644 --- a/rewatch-ocaml/ast_header.ml +++ b/rewatch-ocaml/ast_header.ml @@ -46,4 +46,8 @@ let read_file path = let read path = match Build_file_store.cached path with | Some contents -> of_contents contents |> Option.value ~default:damaged - | None -> read_file path + | None -> ( + try read_file path + with Unix.Unix_error (error, operation, "") -> + (* Unix.read does not name the file it failed to read. *) + raise (Unix.Unix_error (error, operation, path))) diff --git a/rewatch-ocaml/build.ml b/rewatch-ocaml/build.ml index 43152038e71..cb84b00b82b 100644 --- a/rewatch-ocaml/build.ml +++ b/rewatch-ocaml/build.ml @@ -88,15 +88,6 @@ let run_namespace_jobs (attempt : Build_attempt.t) = jobs results); List.length jobs -let write_build_ninja (attempt : Build_attempt.t) = - (* This empty file is a cache-invalidation marker consumed by editor tooling, - not a serialized build plan. Only commands that reconstruct the project - graph call this function. *) - Build_session.iter_package_plans attempt.session (fun _ package -> - let path = Filename.concat package.Package_plan.build_dir "build.ninja" in - let channel = open_out_bin path in - close_out channel) - let incremental_sources (previous : retained_build) changes = (* Reusing the graph is safe only for modifications of already-known source paths. Additions, removals, and unknown paths can change module identity or @@ -165,8 +156,7 @@ let prepare_incremental previous changes (attempt : Build_attempt.t) let results = sources |> List.map (fun source -> - ( source.package.build_dir, - source.package.ocaml_dir, + ( source.package.artifact_dir, source.package.compile_config, source.source.relative_path )) |> Compiler_process.run_parses ?poll:attempt.process_poll @@ -197,7 +187,7 @@ let prepare_incremental previous changes (attempt : Build_attempt.t) if not changed_parse_failed then let raw_dependencies = Module_graph.raw_dependencies - ~build_dir:package.Package_plan.build_dir + ~artifact_dir:package.Package_plan.artifact_dir ~parse_failed:(fun _ -> false) module_ in @@ -253,11 +243,6 @@ let run_with_warning_state ~poll ~warning_state ~request ~no_timing ~verbosity let one_shot = kind = Build_report.One_shot in let watch = not one_shot in let is_rebuild = kind = Build_report.Incremental_watch in - let should_write_build_ninja = - match kind with - | Build_report.One_shot | Build_report.Full_watch -> true - | Build_report.Initial_watch | Build_report.Incremental_watch -> false - in let root = Project_context.canonical_project_root folder in let root_config = match reused_build request with @@ -299,9 +284,6 @@ let run_with_warning_state ~poll ~warning_state ~request ~no_timing ~verbosity (* Each build reaches this at most once: the failure reports end by raising Reported_failure, and a parse failure is raised before any other outcome writes the marker. *) - let write_build_ninja () = - if should_write_build_ninja then write_build_ninja attempt - in let phase_seconds seconds = if no_timing then 0. else seconds in let parse_step = Build_report.parse_step report in let compile_step = Build_report.compile_step report in @@ -313,7 +295,6 @@ let run_with_warning_state ~poll ~warning_state ~request ~no_timing ~verbosity prerr_string output; prerr_newline (); Build_attempt.cleanup_artifacts attempt; - write_build_ninja (); raise (Reported_failure ("Incremental build failed. Error: \027[2K\r Failed to Compile. " @@ -323,7 +304,6 @@ let run_with_warning_state ~poll ~warning_state ~request ~no_timing ~verbosity Build_attempt.finalize_logs attempt; Build_report.report_parse_failure report ~output; Build_attempt.cleanup_artifacts attempt; - write_build_ninja (); raise (Reported_failure "Incremental build failed. Error: \027[2K\r Could not parse Source \ @@ -448,16 +428,8 @@ let run_with_warning_state ~poll ~warning_state ~request ~no_timing ~verbosity let diagnostics = Build_report.print_success_details report ~compile_seconds in - let context = prepared.compiler_context in - Build_session.publish_compiler_info attempt.session (fun package -> - let package_context = - Compiler_info.for_package context - package.Package_plan.compile_config - in - Compiler_info.write_package package_context package.config); if one_shot then Build_report.report_completion report diagnostics; Build_attempt.cleanup_artifacts attempt; - write_build_ninja (); release_build_lock (); Option.iter (fun command -> After_build.run ?poll:process_poll ~root command) @@ -467,6 +439,7 @@ let run_with_warning_state ~poll ~warning_state ~request ~no_timing ~verbosity Build_lock.with_build ~poll build_lock_root (fun ~release:release_build_lock -> Build_attempt.protect attempt (fun () -> + Build_file_store.set_held_writes Compiler_process.is_held; Build_file_store.with_build (fun () -> try execute ~release_build_lock with Parse_failure output -> report_parse_failure output))); @@ -489,12 +462,11 @@ let remove_compile_warning_freshness warning_state = Filename.chop_suffix entry.path "i" else entry.path in + let artifact_dir = Build_artifacts.artifact_dir entry.package_root in [implementation; implementation ^ "i"] |> List.iter (fun source -> - File_util.remove_file - (Build_artifacts.published_ast_path - ~ocaml_dir:(Build_artifacts.lib_path entry.package_root "ocaml") - source))) + Build_artifacts.invalidate_ast + (Build_artifacts.ast_path ~artifact_dir source))) let watch ~verbosity ~folder ~prod ~features ~warn_error ~after_build ~filter ~clear_screen = diff --git a/rewatch-ocaml/build_artifacts.ml b/rewatch-ocaml/build_artifacts.ml index 2b48144049d..6d16c3ea345 100644 --- a/rewatch-ocaml/build_artifacts.ml +++ b/rewatch-ocaml/build_artifacts.ml @@ -1,5 +1,35 @@ let lib_path root directory = File_util.path_of_parts root ["lib"; directory] +(* Every artifact of a package, flat and keyed by the compiler's file name of + its module: ASTs, compiler outputs, logs, build state and locks. *) +let artifact_dir root = lib_path root "rescript" + +(* Where ReScript 12 and earlier kept the artifacts: nested by source + directory in lib/bs, and copied flat into lib/ocaml. *) +let legacy_artifact_dirs root = [lib_path root "bs"; lib_path root "ocaml"] + +(* Locks live in the artifact directory of the project that takes them, next + to the candidates they are published from (see Build_lock). *) +let lock_names = ["build.lock"; "watch.lock"] +let lock_candidate_prefixes = [".build-lock-"; ".watch-lock-"] + +let is_lock_file name = + List.exists (fun lock -> name = lock || name = lock ^ ".takeover") lock_names + || List.exists + (fun prefix -> String.starts_with ~prefix name) + lock_candidate_prefixes + +(* Removes every artifact of a package, and the directories of earlier + versions. A clean runs while it holds the lock, so locks stay. *) +let clean root = + let directory = artifact_dir root in + (try File_util.directory_entries directory + with Unix.Unix_error ((Unix.ENOENT | Unix.ENOTDIR), _, _) -> []) + |> List.iter (fun name -> + if not (is_lock_file name) then + File_util.remove_tree (Filename.concat directory name)); + List.iter File_util.remove_tree (legacy_artifact_dirs root) + let relative_output_directory path (spec : Config.package_spec) = let directory = Filename.dirname path in if spec.in_source then directory @@ -20,13 +50,16 @@ let generated_js_path (config : Config.t) path (spec : Config.package_spec) = (Filename.remove_extension (Filename.basename path) ^ Config.package_spec_suffix config spec))) -let published_ast_path ~ocaml_dir source = - Filename.concat ocaml_dir (Filename.basename (Source.ast_path source)) +let ast_path ~artifact_dir source = + Filename.concat artifact_dir (Source.ast_path source) -let generated_build_js_path ~build_dir (config : Config.t) path - (spec : Config.package_spec) = - Filename.concat build_dir - (Filename.remove_extension path ^ Config.package_spec_suffix config spec) +(* The next build parses the source of an AST older than it, so dating the AST + back makes the next build parse it again while keeping it: it is the only + copy, and a later compile of this build or of the watch session may still + read it. (A time of 0 would mean now to Unix.utimes.) *) +let invalidate_ast path = + try Unix.utimes path 1. 1. + with Unix.Unix_error ((Unix.ENOENT | Unix.ENOTDIR), _, _) -> () let remove_public_outputs (config : Config.t) implementation_paths = List.iter @@ -73,35 +106,16 @@ type cleanup_result = { present_public_outputs: (string, unit) Hashtbl.t; } -let cleanup_stale ~ocaml_files ~ast_sources ~source_files ~present_source_files - ~on_removed_module ~on_deferred_artifact ~root ~is_local (config : Config.t) - modules = - let build_dir = lib_path root "bs" in - (* The caller passes one inventory of each artifact tree to avoid repeating - directory and metadata work during every cleanup phase. Paths removed - below can safely remain in the inventory: later phases only classify their - names or call the idempotent File_util.remove_file. *) - (* Published ASTs contain the absolute source path used to create them, which - is enough to address their working artifacts without scanning for them. - Keep the recursive walk lazy for malformed or legacy ASTs that cannot be - mapped; normal unchanged builds must not inventory the whole lib/bs tree. *) - let fallback_build_files_by_basename = - lazy - (let by_basename = Hashtbl.create 32 in - File_util.files_under build_dir - |> List.iter (fun path -> - let basename = Filename.basename path in - let paths = - Hashtbl.find_opt by_basename basename |> Option.value ~default:[] - in - Hashtbl.replace by_basename basename (path :: paths)); - by_basename) - in +let cleanup_stale ~artifact_files ~ast_sources ~present_source_files + ~on_removed_module ~root (config : Config.t) modules = + (* The caller passes one inventory of the artifact directory to avoid + repeating directory and metadata work during every cleanup phase. Paths + removed below can safely remain in the inventory: later phases only + classify their names or call the idempotent File_util.remove_file. *) let output_files = [lib_path "" "es6"; lib_path "" "js"] - |> List.map (fun directory -> - let output_dir = Filename.concat root directory in - (output_dir, File_util.files_under output_dir)) + |> List.concat_map (fun directory -> + File_util.files_under (Filename.concat root directory)) in let configured_suffixes = List.map (Config.package_spec_suffix config) config.package_specs @@ -116,13 +130,16 @@ let cleanup_stale ~ocaml_files ~ast_sources ~source_files ~present_source_files in let output_details = generated_output_details_for_suffixes output_suffixes in let present_public_outputs = Hashtbl.create 64 in - present_source_files @ List.concat_map snd output_files + present_source_files @ output_files |> List.iter (fun path -> if Option.is_some (output_details path) && File_util.is_regular_file path then Hashtbl.replace present_public_outputs path ()); (* Expected outputs may use arbitrary configured suffixes, including suffixes that do not resemble JavaScript. Probe those paths directly rather than treating a filename heuristic as the source of truth. *) + let expected_outputs = + Hashtbl.create (List.length modules * List.length config.package_specs) + in List.iter (fun module_ -> List.iter @@ -130,14 +147,13 @@ let cleanup_stale ~ocaml_files ~ast_sources ~source_files ~present_source_files let output = generated_js_path config module_.Source.implementation spec in + Hashtbl.replace expected_outputs output (); if (not (Hashtbl.mem present_public_outputs output)) && File_util.is_regular_file output then Hashtbl.replace present_public_outputs output ()) config.package_specs) modules; - let expected_artifacts = Hashtbl.create (List.length modules * 8) in - let owned_output_names = Hashtbl.create (List.length modules * 2) in let current_sources = Hashtbl.create (List.length modules * 2) in List.iter (fun module_ -> @@ -146,6 +162,8 @@ let cleanup_stale ~ocaml_files ~ast_sources ~source_files ~present_source_files Filename.concat root source |> Platform.normalize_path_for_comparison |> fun source -> Hashtbl.replace current_sources source ())) modules; + (* An AST records its source, so the AST of a source that is gone proves + which public outputs the build generated for it. *) let stale_ast_basenames = Hashtbl.create 8 in let removed_output_paths = Hashtbl.create 8 in List.iter @@ -166,26 +184,13 @@ let cleanup_stale ~ocaml_files ~ast_sources ~source_files ~present_source_files ()) config.package_specs))) ast_sources; + let expected_artifacts = Hashtbl.create (List.length modules * 8) in let add_expected base extensions = List.iter (fun extension -> Hashtbl.replace expected_artifacts (base ^ extension) ()) extensions in - let previous_ast_count = ref 0 in - ocaml_files - |> List.iter (fun path -> - let basename = Filename.basename path in - if Filename.check_suffix basename ".ast" then ( - incr previous_ast_count; - Hashtbl.replace owned_output_names - (Filename.chop_suffix basename ".ast") - ()) - else if Filename.check_suffix basename ".iast" then ( - incr previous_ast_count; - Hashtbl.replace owned_output_names - (Filename.chop_suffix basename ".iast") - ())); List.iter (fun module_ -> let source_base = @@ -195,160 +200,45 @@ let cleanup_stale ~ocaml_files ~ast_sources ~source_files ~present_source_files let compiler_base = Source.compiler_asset_basename config module_.Source.implementation in - Hashtbl.replace owned_output_names source_base (); - add_expected source_base [".ast"; ".res"]; + add_expected source_base [".ast"]; if Option.is_some module_.Source.interface then ( - add_expected source_base [".iast"; ".resi"]; + add_expected source_base [".iast"]; add_expected compiler_base [".cmti"]); add_expected compiler_base [".cmi"; ".cmj"; ".cmt"]) modules; Config.namespace_compiler_name config.namespace |> Option.iter (fun namespace -> add_expected namespace [".cmi"; ".cmj"; ".cmt"; ".mlmap"]); + let previous_ast_count = ref 0 in let removed_modules = ref [] in - (* Once the published CMI is removed, bsc still consults the working CMI to - produce its source-located missing-module diagnostic. Keep only that copy - through compilation; the command finalizer removes every deferred path. *) - let defer_working_cmi_until_after_compile basename = - Filename.check_suffix basename ".cmi" - in - let mapped_source_directories = - Hashtbl.create (List.length ast_sources * 2) - in - let add_mapped_source_directory key directory = - let directories = - Hashtbl.find_opt mapped_source_directories key |> Option.value ~default:[] - in - Hashtbl.replace mapped_source_directories key (directory :: directories) - in - List.iter - (fun (ast_source : Compile_assets.ast_source) -> - let source = ast_source.source_path in - Project_context.relative_to_opt root source - |> Option.iter (fun relative_source -> - let directory = Filename.dirname relative_source in - let source_base = - relative_source |> Filename.basename |> Filename.remove_extension - in - add_mapped_source_directory source_base directory; - add_mapped_source_directory - (Source.compiler_asset_basename config relative_source) - directory)) - ast_sources; - let directly_mapped_working_paths basename = - let extension = Filename.extension basename in - if extension = ".mlmap" then [Filename.concat build_dir basename] - else - Hashtbl.find_opt mapped_source_directories - (Filename.remove_extension basename) - |> Option.value ~default:[] - |> List.map (fun directory -> - Filename.concat build_dir (Filename.concat directory basename)) - |> List.sort_uniq String.compare - in - let working_paths basename = - match directly_mapped_working_paths basename with - | _ :: _ as paths -> paths - | [] -> - Hashtbl.find_opt (Lazy.force fallback_build_files_by_basename) basename - |> Option.value ~default:[] - in - ocaml_files + artifact_files |> List.iter (fun path -> let basename = Filename.basename path in - let managed = Compile_assets.is_managed_basename basename in + let is_ast = + Filename.check_suffix basename ".ast" + || Filename.check_suffix basename ".iast" + in + if is_ast then incr previous_ast_count; if - managed + Compile_assets.is_managed_basename basename && ((not (Hashtbl.mem expected_artifacts basename)) || Hashtbl.mem stale_ast_basenames basename) then ( - if - Filename.check_suffix basename ".ast" - || Filename.check_suffix basename ".iast" - then ( + if is_ast then ( let module_name = Source.module_name basename in on_removed_module module_name; removed_modules := module_name :: !removed_modules); - File_util.remove_file path; - working_paths basename - |> List.iter (fun build_path -> - if defer_working_cmi_until_after_compile basename then - on_deferred_artifact build_path - else File_util.remove_file build_path))); - let relative_under directory path = - let prefix = directory ^ Filename.dir_sep in - String.sub path (String.length prefix) - (String.length path - String.length prefix) - in - let expected_outputs = - Hashtbl.create (List.length modules * List.length config.package_specs) - in - List.iter - (fun module_ -> - List.iter - (fun spec -> - Hashtbl.replace expected_outputs - (generated_js_path config module_.Source.implementation spec) - ()) - config.package_specs) - modules; - let should_remove_output ~build_relative path = - output_details path - |> Option.fold ~none:false ~some:(fun (name, _, output_path) -> - (not (Hashtbl.mem expected_outputs output_path)) - && (Hashtbl.mem removed_output_paths output_path - || Hashtbl.mem owned_output_names name - (* A map alone is not enough provenance to delete a public file. The - mirrored output has the same relative path below lib/bs, so probe - that one path instead of scanning the entire working tree. *) - && is_local - && File_util.exists (Filename.concat build_dir build_relative))) - in - let planned_outputs = Hashtbl.create 16 in - let plan_output ~build_relative path = - output_details path - |> Option.iter (fun (_, _, output_path) -> - if should_remove_output ~build_relative output_path then - Hashtbl.replace planned_outputs output_path build_relative) - in - source_files + (* A removed module's interface goes at once: dependents that still + name the module must not compile against it. *) + File_util.remove_file path)); + removed_output_paths |> Hashtbl.to_seq_keys |> List.of_seq + |> List.filter (fun path -> not (Hashtbl.mem expected_outputs path)) + |> List.sort String.compare |> List.iter (fun path -> - output_details path - |> Option.iter (fun (_, _, output_path) -> - plan_output - ~build_relative:(relative_under root output_path) - output_path)); - ast_sources - |> List.iter (fun (ast_source : Compile_assets.ast_source) -> - let source = ast_source.source_path in - Project_context.relative_to_opt root source - |> Option.iter (fun relative_source -> - List.iter - (fun spec -> - let output = generated_js_path config relative_source spec in - plan_output ~build_relative:(relative_under root output) output) - config.package_specs)); - output_files - |> List.iter (fun (output_dir, files) -> - files - |> List.iter (fun path -> - output_details path - |> Option.iter (fun (_, _, output_path) -> - plan_output - ~build_relative:(relative_under output_dir output_path) - output_path))); - let remove_output (path, build_relative) = - Hashtbl.remove present_public_outputs path; - Hashtbl.remove present_public_outputs (path ^ ".map"); - File_util.remove_file path; - File_util.remove_file (path ^ ".map"); - let working_output = Filename.concat build_dir build_relative in - File_util.remove_file working_output; - File_util.remove_file (working_output ^ ".map") - in - planned_outputs |> Hashtbl.to_seq |> List.of_seq - |> List.sort (fun (left, _) (right, _) -> String.compare left right) - |> List.iter remove_output; + Hashtbl.remove present_public_outputs path; + Hashtbl.remove present_public_outputs (path ^ ".map"); + File_util.remove_file path; + File_util.remove_file (path ^ ".map")); { removed_modules = !removed_modules; previous_ast_count = !previous_ast_count; diff --git a/rewatch-ocaml/build_artifacts.mli b/rewatch-ocaml/build_artifacts.mli index e72b9c7c649..72f9e94ed8a 100644 --- a/rewatch-ocaml/build_artifacts.mli +++ b/rewatch-ocaml/build_artifacts.mli @@ -8,26 +8,36 @@ type cleanup_result = { one unit so an earlier deletion cannot erase evidence needed for a later ownership decision. *) -val lib_path : string -> string -> string +val artifact_dir : string -> string +(** [lib/rescript] below a package root. *) + +val legacy_artifact_dirs : string -> string list +(** [lib/bs] and [lib/ocaml] below a package root, from ReScript 12 and + earlier. *) + +val clean : string -> unit +(** Removes the artifacts below a package root, except locks, and the legacy + artifact directories. *) + val relative_output_directory : string -> Config.package_spec -> string -val published_ast_path : ocaml_dir:string -> string -> string -val generated_js_path : Config.t -> string -> Config.package_spec -> string +val ast_path : artifact_dir:string -> string -> string +(** The AST of a package-relative source path. *) + +val invalidate_ast : string -> unit +(** Makes the next build parse the source of an AST again, without removing + the AST. *) -val generated_build_js_path : - build_dir:string -> Config.t -> string -> Config.package_spec -> string +val generated_js_path : Config.t -> string -> Config.package_spec -> string val remove_public_outputs : Config.t -> string list -> unit val cleanup_stale : - ocaml_files:string list -> + artifact_files:string list -> ast_sources:Compile_assets.ast_source list -> - source_files:string list -> present_source_files:string list -> on_removed_module:(string -> unit) -> - on_deferred_artifact:(string -> unit) -> root:string -> - is_local:bool -> Config.t -> Source.module_ list -> cleanup_result diff --git a/rewatch-ocaml/build_attempt.ml b/rewatch-ocaml/build_attempt.ml index 9fcc0890ffc..651edd84856 100644 --- a/rewatch-ocaml/build_attempt.ml +++ b/rewatch-ocaml/build_attempt.ml @@ -27,7 +27,6 @@ type pending_work = { type finalization_state = { mutable actions: (unit -> unit) list; - mutable artifacts: string list; initialized_logs: (string, unit) Hashtbl.t; mutable artifacts_cleaned: bool; mutable logs_finalized: bool; @@ -80,7 +79,6 @@ let create ~freshness_mode ~session ~process_poll ~progress ~verbosity = finalization = { actions = []; - artifacts = []; initialized_logs = Hashtbl.create 16; artifacts_cleaned = false; logs_finalized = false; @@ -107,9 +105,6 @@ let create_retained ~session ~process_poll ~progress ~verbosity = let register_cleanup attempt action = attempt.finalization.actions <- action :: attempt.finalization.actions -let defer_artifact_cleanup attempt paths = - attempt.finalization.artifacts <- paths @ attempt.finalization.artifacts - let set_cleanup_result attempt root (result : Build_artifacts.cleanup_result) = Hashtbl.replace attempt.package_removed_modules root result.removed_modules; Build_session.set_public_outputs attempt.session root @@ -153,11 +148,7 @@ let run_all actions = let cleanup_artifacts attempt = if not attempt.finalization.artifacts_cleaned then ( attempt.finalization.artifacts_cleaned <- true; - run_all - (attempt.finalization.actions - @ List.map - (fun path () -> File_util.remove_file path) - attempt.finalization.artifacts)) + run_all attempt.finalization.actions) let finalize_logs attempt = if not attempt.finalization.logs_finalized then ( diff --git a/rewatch-ocaml/build_attempt.mli b/rewatch-ocaml/build_attempt.mli index db40bf19f1a..4e486f25e6e 100644 --- a/rewatch-ocaml/build_attempt.mli +++ b/rewatch-ocaml/build_attempt.mli @@ -60,7 +60,6 @@ val create_retained : t val register_cleanup : t -> (unit -> unit) -> unit -val defer_artifact_cleanup : t -> string list -> unit val set_cleanup_result : t -> string -> Build_artifacts.cleanup_result -> unit (** Records the modules this attempt removed from a package, and keeps the diff --git a/rewatch-ocaml/build_freshness.ml b/rewatch-ocaml/build_freshness.ml index 93eb79b707e..58ec3ba0103 100644 --- a/rewatch-ocaml/build_freshness.ml +++ b/rewatch-ocaml/build_freshness.ml @@ -1,6 +1,10 @@ +(* An AST dated back to time 1 (Build_artifacts.invalidate_ast) is parsed + again even when its source is dated earlier still, as sources from archives + built with SOURCE_DATE_EPOCH=0 are. *) let source_requires_parse source_modified artifact_modified = match (source_modified, artifact_modified) with - | Some source_time, Some artifact_time -> source_time >= artifact_time + | Some source_time, Some artifact_time -> + artifact_time <= 1. || source_time >= artifact_time | Some _, None -> true | None, _ -> false @@ -15,21 +19,20 @@ let source_is_not_older_than_ast compile_assets ~root ~source_mtimes path = match Compile_assets.ast compile_assets absolute with | Some ast -> Some ast.modified | None -> - let published_ast = - Build_artifacts.published_ast_path - ~ocaml_dir:(Build_artifacts.lib_path root "ocaml") + let ast = + Build_artifacts.ast_path + ~artifact_dir:(Build_artifacts.artifact_dir root) path in let belongs_to_source = try - match (Ast_header.read published_ast).source with + match (Ast_header.read ast).source with | Some source -> Platform.normalize_path_for_comparison source = Platform.normalize_path_for_comparison absolute | None -> false with Unix.Unix_error ((Unix.ENOENT | Unix.ENOTDIR), _, _) -> false in - if belongs_to_source then File_util.modification_time published_ast - else None + if belongs_to_source then File_util.modification_time ast else None in source_requires_parse source_modified artifact_modified diff --git a/rewatch-ocaml/build_lock.ml b/rewatch-ocaml/build_lock.ml index 9dc5a8cfd2f..3d5a9f3398c 100644 --- a/rewatch-ocaml/build_lock.ml +++ b/rewatch-ocaml/build_lock.ml @@ -63,6 +63,7 @@ let process_is_active ?poll value = with Process.Error _ | Unix.Unix_error _ | Sys_error _ -> None) let with_candidate ~lock_dir prefix pid action = + File_util.ensure_dir lock_dir; let path, output = Filename.open_temp_file ~temp_dir:lock_dir prefix ".tmp" in Fun.protect ~finally:(fun () -> File_util.remove_file_best_effort path) @@ -124,7 +125,7 @@ let with_acquired ~candidate ~path ~pid action = let acquire ?poll ~name ~prefix ~attempts ~delay ~timeout ~on_live_owner root action = - let lock_dir = Filename.concat root "lib" in + let lock_dir = Build_artifacts.artifact_dir root in File_util.ensure_dir lock_dir; let path = Filename.concat lock_dir name in let pid = string_of_int (Platform.current_process_id ()) in diff --git a/rewatch-ocaml/build_preparation.ml b/rewatch-ocaml/build_preparation.ml index 8edb62a2db9..52648703a2a 100644 --- a/rewatch-ocaml/build_preparation.ml +++ b/rewatch-ocaml/build_preparation.ml @@ -37,13 +37,13 @@ let run ~(root_config : Config.t) ~prod ~features ~warn_error ~filter ~watch in let previous_compile_assets = package_plans - |> List.map (fun (package : Package_plan.t) -> package.ocaml_dir) + |> List.map (fun (package : Package_plan.t) -> package.artifact_dir) |> Compile_assets.create in let dependents_by_raw_dependency = Hashtbl.create 64 in package_plans |> List.concat_map (fun (package : Package_plan.t) -> - Compile_assets.ast_sources previous_compile_assets package.ocaml_dir) + Compile_assets.ast_sources previous_compile_assets package.artifact_dir) |> List.iter (fun (ast_source : Compile_assets.ast_source) -> Compile_assets.ast_dependencies previous_compile_assets ast_source.ast_path @@ -63,23 +63,22 @@ let run ~(root_config : Config.t) ~prod ~features ~warn_error ~filter ~watch |> Option.value ~default:[] in (* A cleanup failure can end the attempt before dependency preparation - records why consumers need recompilation. Remove their freshness + records why consumers need recompilation. Invalidate their freshness markers when the attempt finishes so the next invocation cannot reuse them, while the current invocation can still compile from the existing AST and report the source-level missing-module error. *) Build_attempt.register_cleanup attempt (fun () -> - List.iter File_util.remove_file dependent_asts)) + List.iter Build_artifacts.invalidate_ast dependent_asts)) in - let cleanup_stale (package : Package_plan.t) ~on_deferred_artifact = + let cleanup_stale (package : Package_plan.t) = Build_artifacts.cleanup_stale - ~ocaml_files: - (Compile_assets.files previous_compile_assets package.ocaml_dir) + ~artifact_files: + (Compile_assets.files previous_compile_assets package.artifact_dir) ~ast_sources: - (Compile_assets.ast_sources previous_compile_assets package.ocaml_dir) - ~root:package.root ~source_files:package.source_files - ~present_source_files:package.present_source_files - ~on_removed_module:invalidate_removed_module ~on_deferred_artifact - ~is_local:package.is_local package.compile_config package.modules + (Compile_assets.ast_sources previous_compile_assets package.artifact_dir) + ~root:package.root ~present_source_files:package.present_source_files + ~on_removed_module:invalidate_removed_module package.compile_config + package.modules in (* Outputs written under the previous package-specs are removed before the package is cleaned, because the new specs no longer name them. *) @@ -95,7 +94,7 @@ let run ~(root_config : Config.t) ~prod ~features ~warn_error ~filter ~watch (fun (module_ : Source.module_) -> module_.implementation) package.modules @ (Compile_assets.ast_sources previous_compile_assets - package.ocaml_dir + package.artifact_dir |> List.filter_map (fun (source : Compile_assets.ast_source) -> if Filename.check_suffix source.ast_path ".iast" then None else @@ -108,9 +107,9 @@ let run ~(root_config : Config.t) ~prod ~features ~warn_error ~filter ~watch in let cleanup_started = Unix.gettimeofday () in (* A package that needs cleaning has its stale outputs removed before its - lib/bs and lib/ocaml trees are wiped, while the lib/bs mirror still - identifies which public outputs it owns. That cleanup result is final, so - the second pass only cleans up the remaining packages. *) + artifact directory is emptied, while its ASTs still identify which public + outputs it owns. That cleanup result is final, so the second pass only + cleans up the remaining packages. *) let cleanups_before_clean = List.map (fun (package : Package_plan.t) -> @@ -120,16 +119,16 @@ let run ~(root_config : Config.t) ~prod ~features ~warn_error ~filter ~watch let cleanup = if Compiler_info.needs_clean package_context package.config then ( remove_previous_spec_outputs package package_context; - let cleanup = - cleanup_stale package ~on_deferred_artifact:File_util.remove_file - in + let cleanup = cleanup_stale package in Compiler_info.clean_package package.config; attempt.compiler_cleaned <- true; Some cleanup) else None in - File_util.ensure_dir package.build_dir; - File_util.ensure_dir package.ocaml_dir; + File_util.ensure_dir package.artifact_dir; + (* Recorded once the package matches this compiler, so that a failed + or interrupted build does not clean it again. *) + Compiler_info.write_package package_context package.config; (package, cleanup)) package_plans in @@ -138,9 +137,7 @@ let run ~(root_config : Config.t) ~prod ~features ~warn_error ~filter ~watch let cleanup = match cleanup with | Some cleanup -> cleanup - | None -> - cleanup_stale package ~on_deferred_artifact:(fun path -> - Build_attempt.defer_artifact_cleanup attempt [path]) + | None -> cleanup_stale package in Build_attempt.set_cleanup_result attempt package.root cleanup; attempt.cleaned <- attempt.cleaned + List.length cleanup.removed_modules; @@ -151,7 +148,7 @@ let run ~(root_config : Config.t) ~prod ~features ~warn_error ~filter ~watch if attempt.compiler_cleaned || Hashtbl.length attempt.removed_modules > 0 then package_plans - |> List.map (fun (package : Package_plan.t) -> package.ocaml_dir) + |> List.map (fun (package : Package_plan.t) -> package.artifact_dir) |> Compile_assets.create else previous_compile_assets in @@ -188,7 +185,7 @@ let run ~(root_config : Config.t) ~prod ~features ~warn_error ~filter ~watch let parse_results = parse_entries |> List.map (fun ((package : Package_plan.t), path, _) -> - (package.build_dir, package.ocaml_dir, package.compile_config, path)) + (package.artifact_dir, package.compile_config, path)) |> Compiler_process.run_parses ?poll:attempt.process_poll ~on_complete:parse_completed in @@ -232,9 +229,7 @@ let run ~(root_config : Config.t) ~prod ~features ~warn_error ~filter ~watch let regular_dependency_dirs, development_dependency_dirs = List.fold_left (fun (regular, development) (dependency : Package_plan.dependency) -> - let directory = - Build_artifacts.lib_path dependency.directory "ocaml" - in + let directory = Build_artifacts.artifact_dir dependency.directory in match dependency.kind with | Package_traversal.Regular -> (directory :: regular, development) | Package_traversal.Development -> diff --git a/rewatch-ocaml/build_session.ml b/rewatch-ocaml/build_session.ml index 1e2914b44a7..51459251e92 100644 --- a/rewatch-ocaml/build_session.ml +++ b/rewatch-ocaml/build_session.ml @@ -17,7 +17,6 @@ type readiness = | Freshness_pending of prepared | Ready of prepared -type compiler_info_state = Needs_publication | Published type cycle_cache = | Unknown_cycle | Known_cycle of Module_graph.cycle_info option @@ -33,7 +32,6 @@ type t = { pending_removed_modules: (string, unit) Hashtbl.t; public_outputs: (string, (string, unit) Hashtbl.t) Hashtbl.t; mutable readiness: readiness; - mutable compiler_info_state: compiler_info_state; warning_state: Warning_state.t; } @@ -49,7 +47,6 @@ let create ~warning_state = pending_removed_modules = Hashtbl.create 16; public_outputs = Hashtbl.create 32; readiness = Not_prepared; - compiler_info_state = Needs_publication; warning_state; } @@ -112,13 +109,6 @@ let find_package_plan session root = Hashtbl.find_opt session.package_plans root let iter_package_plans session f = Hashtbl.iter f session.package_plans let package_plan_values session = Hashtbl.to_seq_values session.package_plans -let publish_compiler_info session write = - match session.compiler_info_state with - | Published -> () - | Needs_publication -> - Hashtbl.iter (fun _ package -> write package) session.package_plans; - session.compiler_info_state <- Published - let add_source_reference session normalized_path source = Hashtbl.replace session.source_index normalized_path source diff --git a/rewatch-ocaml/build_session.mli b/rewatch-ocaml/build_session.mli index d89cfb5e9e0..f88a9f34435 100644 --- a/rewatch-ocaml/build_session.mli +++ b/rewatch-ocaml/build_session.mli @@ -44,7 +44,6 @@ val add_package_plan : t -> Package_plan.t -> unit val find_package_plan : t -> string -> Package_plan.t option val iter_package_plans : t -> (string -> Package_plan.t -> unit) -> unit val package_plan_values : t -> Package_plan.t Seq.t -val publish_compiler_info : t -> (Package_plan.t -> unit) -> unit val add_source_reference : t -> string -> source_reference -> unit val find_source_reference : t -> string -> source_reference option val pending_parse_paths : t -> string list diff --git a/rewatch-ocaml/clean.ml b/rewatch-ocaml/clean.ml index 3b766625bbf..e8c1a2a3f23 100644 --- a/rewatch-ocaml/clean.ml +++ b/rewatch-ocaml/clean.ml @@ -80,8 +80,8 @@ let run ~poll ~verbosity ~folder ~prod = (Output.cleaned_command_message ~color:colors ~step ~target ~seconds:(Unix.gettimeofday () -. started_at)) in - Build_lock.with_build ~poll (Project_context.workspace_lock_root root) - (fun ~release:_ -> + let lock_root = Project_context.workspace_lock_root root in + Build_lock.with_build ~poll lock_root (fun ~release:_ -> poll (); let root_config = Config.load_root root in let workspace_config = Project_context.workspace_config_for root_config in diff --git a/rewatch-ocaml/compile_assets.ml b/rewatch-ocaml/compile_assets.ml index b68bb7223c5..96bb5c3ac52 100644 --- a/rewatch-ocaml/compile_assets.ml +++ b/rewatch-ocaml/compile_assets.ml @@ -15,10 +15,13 @@ let ast_header path = with Unix.Unix_error ((Unix.ENOENT | Unix.ENOTDIR), _, _) -> None let cleanup_extensions = - [".cmi"; ".cmj"; ".cmt"; ".cmti"; ".ast"; ".iast"; ".res"; ".resi"; ".mlmap"] + [".cmi"; ".cmj"; ".cmt"; ".cmti"; ".ast"; ".iast"; ".mlmap"] +(* Compiler artifacts, and files a build killed while it published one left + behind. *) let is_managed_basename basename = List.exists (Filename.check_suffix basename) cleanup_extensions + || String.starts_with ~prefix:File_util.atomic_write_prefix basename let state_extension = function | ".ast" | ".iast" | ".cmi" | ".cmt" -> true @@ -31,8 +34,7 @@ let read_directory directory = in let files = names - |> List.filter (fun name -> - List.mem (Filename.extension name) cleanup_extensions) + |> List.filter is_managed_basename |> List.map (Filename.concat directory) in let state_names = diff --git a/rewatch-ocaml/compile_assets.mli b/rewatch-ocaml/compile_assets.mli index 53180ff4d62..b915655f1b4 100644 --- a/rewatch-ocaml/compile_assets.mli +++ b/rewatch-ocaml/compile_assets.mli @@ -1,5 +1,5 @@ type entry = {path: string; modified: float} -(** This index avoids repeatedly scanning [lib/ocaml] while retaining the source +(** This index avoids repeatedly scanning [lib/rescript] while retaining the source provenance embedded in AST headers. Mutating refresh operations must be called whenever publication changes the corresponding filesystem entry. *) @@ -7,6 +7,9 @@ type ast_source = {ast_path: string; source_path: string} type t val is_managed_basename : string -> bool +(** Compiler artifacts, and leftover {!File_util.write_file_atomic} files, + which cleanup removes when no current module expects them. *) + val create : string list -> t val files : t -> string -> string list val ast_sources : t -> string -> ast_source list diff --git a/rewatch-ocaml/compiler_args.ml b/rewatch-ocaml/compiler_args.ml index 81475b3d4dd..dbc16c555a2 100644 --- a/rewatch-ocaml/compiler_args.ml +++ b/rewatch-ocaml/compiler_args.ml @@ -39,7 +39,7 @@ let parser_flags ?(ppx_flags = []) (config : Config.t) = | flag :: arguments -> let executable = (* A path starting with a dot names a file in the package itself; - bsc runs the PPX from lib/bs. *) + bsc runs the PPX from lib/rescript. *) if String.starts_with ~prefix:"." flag then Filename.concat config.root flag else @@ -104,7 +104,7 @@ let parser_arguments ~(config : Config.t) ~contents ~path = let compiler_common_arguments ~project_root ~(config : Config.t) ~runtime ~dependency_dirs ~watch ~gentype_dependency_args = - ["-I"; Filename.concat Filename.parent_dir_name "ocaml"] + ["-I"; Filename.current_dir_name] @ ["-runtime-path"; runtime] @ List.concat_map (fun directory -> ["-I"; directory]) dependency_dirs @ compiler_flags ~watch config diff --git a/rewatch-ocaml/compiler_args_command.ml b/rewatch-ocaml/compiler_args_command.ml index 19cc631bc9e..ff84a7a5b23 100644 --- a/rewatch-ocaml/compiler_args_command.ml +++ b/rewatch-ocaml/compiler_args_command.ml @@ -93,7 +93,7 @@ let run ~verbosity path = Package_resolution.dependency_path resolution ~package_root:config.root dependency.name with - | Some directory -> Some (Build_artifacts.lib_path directory "ocaml") + | Some directory -> Some (Build_artifacts.artifact_dir directory) | None when not required -> None | None -> error diff --git a/rewatch-ocaml/compiler_info.ml b/rewatch-ocaml/compiler_info.ml index 46374dca79b..b9c3a6bd70d 100644 --- a/rewatch-ocaml/compiler_info.ml +++ b/rewatch-ocaml/compiler_info.ml @@ -39,7 +39,8 @@ let make_context ~compiler_path ~compiler_identity ~runtime_path let for_package context config = {context with package_output_specs = package_output_specs config} -let path root = File_util.path_of_parts root ["lib"; "bs"; "compiler-info.json"] +let path root = + Filename.concat (Build_artifacts.artifact_dir root) "compiler-info.json" let package_output_spec_json spec = `Assoc @@ -126,18 +127,20 @@ let config_with_package_output_specs (config : Config.t) specs = in {config with package_specs} -let previous_build_exists root = - File_util.exists - (File_util.path_of_parts root ["lib"; "ocaml"; ".compiler.log"]) +(* A build of ReScript 12 or earlier left lib/bs or lib/ocaml, which the clean + of the next build with this layout removes, also when a build of this + version ran before it, such as on another branch. *) +let legacy_build_exists root = + List.exists File_util.exists (Build_artifacts.legacy_artifact_dirs root) let needs_clean context (config : Config.t) = - let info_path = path config.root in - if File_util.exists info_path then not (matches context config) - else previous_build_exists config.root + legacy_build_exists config.root + || + match read config with + | Some contents -> not (matches_json context config contents) + | None -> false -let clean_package (config : Config.t) = - File_util.remove_tree (Build_artifacts.lib_path config.root "bs"); - File_util.remove_tree (Build_artifacts.lib_path config.root "ocaml") +let clean_package (config : Config.t) = Build_artifacts.clean config.root let write_package context (config : Config.t) = if not (matches context config) then diff --git a/rewatch-ocaml/compiler_log.ml b/rewatch-ocaml/compiler_log.ml index 1c2c9ba26b7..830e2b4272f 100644 --- a/rewatch-ocaml/compiler_log.ml +++ b/rewatch-ocaml/compiler_log.ml @@ -1,5 +1,5 @@ -let path root directory = - Filename.concat (Build_artifacts.lib_path root directory) ".compiler.log" +let path root = + Filename.concat (Build_artifacts.artifact_dir root) ".compiler.log" let strip_ansi content = let length = String.length content in @@ -25,14 +25,12 @@ let strip_ansi content = Buffer.contents output let initialize root = - let path = path root "bs" in + let path = path root in File_util.ensure_dir (Filename.dirname path); File_util.write_file path (Printf.sprintf "#Start(%.6f)\n" (Unix.gettimeofday ())) -let append root content = - File_util.append_file (path root "bs") (strip_ansi content) +let append root content = File_util.append_file (path root) (strip_ansi content) let finalize root = - append root (Printf.sprintf "#Done(%.6f)\n" (Unix.gettimeofday ())); - File_util.copy_existing_file (path root "bs") (path root "ocaml") + append root (Printf.sprintf "#Done(%.6f)\n" (Unix.gettimeofday ())) diff --git a/rewatch-ocaml/compiler_process.ml b/rewatch-ocaml/compiler_process.ml index 99c286e600a..a031d03c7f2 100644 --- a/rewatch-ocaml/compiler_process.ml +++ b/rewatch-ocaml/compiler_process.ml @@ -113,81 +113,122 @@ let run_tasks ?poll ?on_complete tasks = let run_requests ?poll ?on_complete requests = requests |> List.map task |> run_tasks ?poll ?on_complete -let parse_request ~build_dir ~(config : Config.t) path = - let ast = Source.ast_path path in - File_util.ensure_dir (Filename.concat build_dir (Filename.dirname ast)); +(* A request writes its ASTs, interfaces and typed trees into the artifact + directory that later requests and builds read. They are held in memory + until the request finished (Build_file_store.set_held_writes, which the + build installs with this predicate), so a failed request leaves the + previous AST and interface on disk, and a build killed before it published + an interface leaves the typed tree that marks its module compiled stale. *) +let is_held path = + List.exists + (Filename.check_suffix path) + [".ast"; ".iast"; ".cmi"; ".cmt"; ".cmti"] + +(* Renamed into place, so that neither a reader nor a build killed while + writing sees part of a file. On Windows the rename fails while another + process, such as an editor, has the file open without delete sharing; the + file is then written in place, and a write that fails removes its partial + file. *) +let write_held path contents = + try File_util.write_file_atomic ~ensure_parent:false path contents + with Sys_error _ | Unix.Unix_error _ -> ( + try File_util.write_file path contents + with Sys_error message -> + File_util.remove_file_best_effort path; + raise + (Sys_error + (if String_util.contains message path then message + else path ^ ": " ^ message))) + +let parse_request ~artifact_dir ~(config : Config.t) path = let contents = if config.ppx_flags = [] then "" else File_util.read_file (Filename.concat config.root path) in let args = Compiler_args.parser_arguments ~config ~contents ~path in - {args; cwd = build_dir} + {args; cwd = artifact_dir} -(* Runs on the worker that parsed [path], right after the parse, so that - publishing the outputs of a large project's parses does not run on one - domain afterwards. The source is kept: compiling reads it again. *) -let publish_parse ~build_dir ~ocaml_dir ~(config : Config.t) path = - File_util.copy_build_file ~keep:false - (Filename.concat build_dir (Source.ast_path path)) - (Build_artifacts.published_ast_path ~ocaml_dir path); - File_util.copy_build_file - (Filename.concat config.root path) - (Filename.concat ocaml_dir (Filename.basename path)) +(* An AST is written even when it is unchanged: its modification time records + when its source was parsed. *) +let publish_parse ~artifact_dir path = + ignore + (Build_file_store.publish_held ~if_changed:false ~write:write_held + (Build_artifacts.ast_path ~artifact_dir path)) -(* A parse that printed warnings is published later, on the main domain, once - the build has registered the cleanup that makes the next build parse it - again and repeat them. Published now, it would outlive a build interrupted - before that, and the next build would not report the warnings. *) +(* Runs on the worker that parsed [path], right after the parse, so that + publishing the ASTs of a large project's parses does not run on one domain + afterwards. A parse that printed warnings is published later, on the main + domain, once the build has registered the cleanup that makes the next build + parse it again and repeat them. Published now, it would outlive a build + interrupted before that, and the next build would not report the + warnings. *) let run_parses ?poll ?on_complete parses = parses - |> List.map (fun (build_dir, ocaml_dir, config, path) -> + |> List.map (fun (artifact_dir, config, path) -> Process.map_result - (task (parse_request ~build_dir ~config path)) + (task (parse_request ~artifact_dir ~config path)) (fun result -> - if Process.succeeded result && result.stderr = "" then - publish_parse ~build_dir ~ocaml_dir ~config path; + if not (Process.succeeded result) then + Build_file_store.forget + (Build_artifacts.ast_path ~artifact_dir path) + else if result.stderr = "" then publish_parse ~artifact_dir path; result)) |> run_tasks ?poll ?on_complete -type compiler_artifact = Cmi | Required of string | Optional of string +type compiler_artifact = Cmi | Required of string | Typed_tree of string -let publish_compiler_artifacts ~artifact_dir ~ocaml_dir ~basename artifacts = +(* A typed tree marks its module compiled, so it is published last. Not every + compile writes one (-bs-no-bin-annot). *) +let publish_typed_tree path = + match + Build_file_store.publish_held ~if_changed:false ~write:write_held path + with + | exception Not_found -> () + (* Once published, it is only read by gentype, which then finds it on disk. *) + | _ -> Build_file_store.evict path + +(* The compiler wrote the other artifacts into the artifact directory: + interfaces are held until now and written only when they changed, which + keeps the modification time that tells dependents whether to compile + again. Callers list typed trees last. *) +let publish_compiler_artifacts ~artifact_dir ~basename artifacts = let cmi_change = ref Compiler_scheduler.Cmi_change_unknown in try List.iter (fun artifact -> - let extension = - match artifact with - | Cmi -> "cmi" - | Required name | Optional name -> name - in - let source = - Filename.concat artifact_dir (basename ^ "." ^ extension) - in - let destination = - Filename.concat ocaml_dir (basename ^ "." ^ extension) - in - (* Dependents read the published .cmi and .cmj, so the store keeps - them; nothing in the build reads the other copies again. *) - (match artifact with + match artifact with | Cmi -> + let path = Filename.concat artifact_dir (basename ^ ".cmi") in + let changed = + try + Build_file_store.publish_held ~if_changed:true ~write:write_held + path + with Not_found -> + (* The compiler does not write an interface identical to the + one on disk (Cmi_format.create_cmi). *) + if Build_file_store.exists path then false + else raise (Unix.Unix_error (Unix.ENOENT, "open", path)) + in cmi_change := - if File_util.copy_build_file_if_different source destination then - Compiler_scheduler.Cmi_changed + if changed then Compiler_scheduler.Cmi_changed else Compiler_scheduler.Cmi_unchanged - | Required "cmj" -> File_util.copy_build_file source destination - | Required _ -> File_util.copy_build_file ~keep:false source destination - | Optional _ -> - File_util.copy_optional_build_file ~keep:false source destination); - Build_file_store.evict source) + | Required extension -> + let path = + Filename.concat artifact_dir (basename ^ "." ^ extension) + in + if not (Build_file_store.exists path) then + raise (Unix.Unix_error (Unix.ENOENT, "open", path)) + | Typed_tree extension -> + publish_typed_tree + (Filename.concat artifact_dir (basename ^ "." ^ extension))) artifacts; !cmi_change with error -> raise (Compiler_scheduler.Publication_failure (error, !cmi_change)) -let namespace_task ~runtime ~build_dir ~ocaml_dir ~entry ~package_dirty ~force - namespace modules = - let mlmap = Filename.concat build_dir (namespace ^ ".mlmap") in +let namespace_task ~runtime ~artifact_dir ~entry ~package_dirty ~force namespace + modules = + let mlmap = Filename.concat artifact_dir (namespace ^ ".mlmap") in let contents = let buffer = Buffer.create 128 in Buffer.add_string buffer "randjbuildsystem\n"; @@ -206,25 +247,19 @@ let namespace_task ~runtime ~build_dir ~ocaml_dir ~entry ~package_dirty ~force let mlmap_changed = previous_contents <> Some contents in if mlmap_changed then File_util.write_file_atomic ~ensure_parent:false mlmap contents; - let outputs_exist = - ["cmi"; "cmj"; "cmt"; "mlmap"] + let typed_tree = Filename.concat artifact_dir (namespace ^ ".cmt") in + let outputs_current = + ["cmi"; "cmj"; "cmt"] |> List.for_all (fun extension -> File_util.is_regular_file - (Filename.concat ocaml_dir (namespace ^ "." ^ extension))) - in - let published_mlmap_matches = - try - File_util.read_file (Filename.concat ocaml_dir (namespace ^ ".mlmap")) - = contents - with Unix.Unix_error ((Unix.ENOENT | Unix.ENOTDIR), _, _) -> false + (Filename.concat artifact_dir (namespace ^ "." ^ extension))) in - if - not - (force || package_dirty || mlmap_changed - || (not published_mlmap_matches) - || not outputs_exist) - then None - else + if not (force || package_dirty || mlmap_changed || not outputs_current) then + None + else ( + (* The typed tree, published last, marks the namespace compiled: without + it, a build that fails or is killed before then compiles it again. *) + File_util.remove_file typed_tree; Some Compiler_scheduler. { @@ -242,21 +277,25 @@ let namespace_task ~runtime ~build_dir ~ocaml_dir ~entry ~package_dirty ~force "-no-alias-deps"; Filename.basename mlmap; ]; - cwd = build_dir; + cwd = artifact_dir; }; publish = (fun result -> - if not (Process.succeeded result) then + if not (Process.succeeded result) then ( + List.iter + (fun extension -> + Build_file_store.forget + (Filename.concat artifact_dir (namespace ^ extension))) + [".cmi"; ".cmt"]; raise (Compiler_scheduler.Build_failure - (result.Process.stderr ^ result.stdout)); + (result.Process.stderr ^ result.stdout))); let cmi_change = - publish_compiler_artifacts ~artifact_dir:build_dir ~ocaml_dir - ~basename:namespace - [Cmi; Required "cmj"; Required "cmt"; Required "mlmap"] + publish_compiler_artifacts ~artifact_dir ~basename:namespace + [Cmi; Required "cmj"; Typed_tree "cmt"] in Compiler_scheduler.{stderr = result.stderr; cmi_change}); - } + }) let post_build_tasks (config : Config.t) path = match config.js_post_build with @@ -280,7 +319,7 @@ let post_build_tasks (config : Config.t) path = }) config.package_specs -let compile_request ~build_dir ~(config : Config.t) ~common_args +let compile_request ~artifact_dir ~(config : Config.t) ~common_args (module_ : Source.module_) ~source_kind path = let args = Compiler_args.compiler_arguments_with_common ~config ~common_args @@ -288,69 +327,64 @@ let compile_request ~build_dir ~(config : Config.t) ~common_args ~has_interface:(Option.is_some module_.interface) ~path in - {args; cwd = build_dir} + {args; cwd = artifact_dir} + +(* A compile that failed leaves the interface on disk. It publishes the + partial typed tree the compiler wrote, which editor tooling reads, but + first dates its AST back, so that the next build compiles the module again + even if this one is killed before the scheduler records the failure (which + dates the AST back as well). Best effort, so that a file another process + holds does not replace the compile error with a disk error. *) +let discard_compile ~artifact_dir ~(config : Config.t) path = + let artifact extension = + Filename.concat artifact_dir + (Source.compiler_asset_basename config path ^ extension) + in + Build_file_store.forget (artifact ".cmi"); + (try + Build_artifacts.invalidate_ast + (Build_artifacts.ast_path ~artifact_dir path) + with Unix.Unix_error _ -> ()); + let typed_tree = + artifact (if Filename.check_suffix path ".resi" then ".cmti" else ".cmt") + in + try publish_typed_tree typed_tree + with Sys_error _ -> Build_file_store.forget typed_tree -let publish ~build_dir ~ocaml_dir ~is_local ~(config : Config.t) ~has_interface +let publish ~artifact_dir ~is_local ~(config : Config.t) ~has_interface ~source_kind path result = let stderr = if is_local then result.Process.stderr else retain_critical_external_warnings result.stderr in let basename = Source.compiler_asset_basename config path in - let artifact_dir = Filename.concat build_dir (Filename.dirname path) in let cmi_change = ref Compiler_scheduler.Cmi_change_unknown in try (cmi_change := match source_kind with | Source.Interface -> - publish_compiler_artifacts ~artifact_dir ~ocaml_dir ~basename - [Cmi; Optional "cmti"] + publish_compiler_artifacts ~artifact_dir ~basename + [Cmi; Typed_tree "cmti"] | Source.Implementation when has_interface -> (* The implementation is compiled with -bs-read-cmi, so its .cmi is - the one already published after compiling the interface, which - this compile read again. *) + the one published after compiling the interface. *) ignore - (publish_compiler_artifacts ~artifact_dir ~ocaml_dir ~basename - [Required "cmj"; Optional "cmt"]); - Build_file_store.evict - (Filename.concat artifact_dir (basename ^ ".cmi")); + (publish_compiler_artifacts ~artifact_dir ~basename + [Required "cmj"; Typed_tree "cmt"]); Compiler_scheduler.Cmi_unchanged | Source.Implementation -> - publish_compiler_artifacts ~artifact_dir ~ocaml_dir ~basename - [Cmi; Required "cmj"; Optional "cmt"]); - let source = Filename.concat config.root path in - let build_source = Filename.concat build_dir path in - File_util.ensure_dir (Filename.dirname build_source); - File_util.copy_build_file ~keep:false source build_source; - let published_source = Filename.concat ocaml_dir (Filename.basename path) in - (* Usually published unchanged when the source was parsed. *) - ignore - (File_util.copy_build_file_if_different ~keep:false source - published_source); + publish_compiler_artifacts ~artifact_dir ~basename + [Cmi; Required "cmj"; Typed_tree "cmt"]); + (* The parse and the typed tree's source digest read the source through + the store. *) List.iter Build_file_store.evict [ - source; - published_source; - Filename.concat build_dir (Source.ast_path path); + Filename.concat config.root path; + Build_artifacts.ast_path ~artifact_dir path; ]; (match source_kind with | Source.Interface -> () | Source.Implementation -> - List.iter - (fun spec -> - if spec.Config.in_source then ( - let output = Build_artifacts.generated_js_path config path spec in - let build_output = - Build_artifacts.generated_build_js_path ~build_dir config path - spec - in - File_util.ensure_dir (Filename.dirname build_output); - Option.iter - (File_util.write_build_file ~keep:false build_output) - (Build_file_store.read output); - File_util.copy_optional_build_file ~keep:false (output ^ ".map") - (build_output ^ ".map"))) - config.package_specs; List.iter (fun spec -> let output = Build_artifacts.generated_js_path config path spec in diff --git a/rewatch-ocaml/compiler_process.mli b/rewatch-ocaml/compiler_process.mli index 5c1aba42dba..8a1b203df41 100644 --- a/rewatch-ocaml/compiler_process.mli +++ b/rewatch-ocaml/compiler_process.mli @@ -5,7 +5,11 @@ type request = {args: string list; cwd: string} (** A request for the embedded compiler: [bsc]'s arguments, ending with the input file, and the directory it runs in. *) -val parse_request : build_dir:string -> config:Config.t -> string -> request +val is_held : string -> bool +(** The outputs a build holds in memory until their request finished (see + {!Build_file_store.set_held_writes}): ASTs, interfaces and typed trees. *) + +val parse_request : artifact_dir:string -> config:Config.t -> string -> request val run : ?poll:(unit -> unit) -> request -> Process.result val run_requests : @@ -14,25 +18,24 @@ val run_requests : request list -> Process.result list -val publish_parse : - build_dir:string -> ocaml_dir:string -> config:Config.t -> string -> unit -(** Publishes the AST and the source of a successful parse into [ocaml_dir]. *) +val publish_parse : artifact_dir:string -> string -> unit +(** Writes the AST of a successful parse to the artifact directory. *) val run_parses : ?poll:(unit -> unit) -> ?on_complete:(int -> unit) -> - (string * string * Config.t * string) list -> + (string * Config.t * string) list -> Process.result list -(** Parses each [(build_dir, ocaml_dir, config, path)], publishing every - successful parse that printed nothing with {!publish_parse} on the worker - that parsed it. The caller publishes the parses that printed warnings. *) +(** Parses each [(artifact_dir, config, path)], publishing every successful + parse that printed nothing with {!publish_parse} on the worker that parsed + it, and discarding every failed one. The caller publishes the parses that + printed warnings. *) val task : request -> Process.task val namespace_task : runtime:string -> - build_dir:string -> - ocaml_dir:string -> + artifact_dir:string -> entry:string option -> package_dirty:bool -> force:bool -> @@ -41,7 +44,7 @@ val namespace_task : Compiler_scheduler.namespace_task option val compile_request : - build_dir:string -> + artifact_dir:string -> config:Config.t -> common_args:string list -> Source.module_ -> @@ -52,9 +55,12 @@ val compile_request : val post_build_tasks : Config.t -> string -> Compiler_scheduler.post_build_task list +val discard_compile : artifact_dir:string -> config:Config.t -> string -> unit +(** Leaves the previous interface of a compile that failed on disk, dates its + AST back and publishes its partial typed tree. *) + val publish : - build_dir:string -> - ocaml_dir:string -> + artifact_dir:string -> is_local:bool -> config:Config.t -> has_interface:bool -> diff --git a/rewatch-ocaml/compiler_scheduler.ml b/rewatch-ocaml/compiler_scheduler.ml index 7d2e1a9dbdb..3d59c78ef9a 100644 --- a/rewatch-ocaml/compiler_scheduler.ml +++ b/rewatch-ocaml/compiler_scheduler.ml @@ -272,12 +272,12 @@ let run ~poll ~warning_state ~compile_assets ~build_state ~candidates false in let invalidate_persistent_freshness (scheduled : scheduled_module) = - let ocaml_dir = Filename.dirname scheduled.cmi_path in + let artifact_dir = Filename.dirname scheduled.cmi_path in scheduled.source.Source.implementation :: Option.to_list scheduled.source.Source.interface |> List.iter (fun source -> - let path = Build_artifacts.published_ast_path ~ocaml_dir source in - File_util.remove_file path; + let path = Build_artifacts.ast_path ~artifact_dir source in + Build_artifacts.invalidate_ast path; Compile_assets.refresh_ast compile_assets ~source:(Filename.concat scheduled.package_root source) ~path) diff --git a/rewatch-ocaml/file_util.ml b/rewatch-ocaml/file_util.ml index 68a0ad80ede..1654f9b632f 100644 --- a/rewatch-ocaml/file_util.ml +++ b/rewatch-ocaml/file_util.ml @@ -100,10 +100,12 @@ let directory_entries path = in read []) +let atomic_write_prefix = ".rewatch-write-" + let write_file_atomic ?(ensure_parent = true) path contents = if ensure_parent then ensure_dir (Filename.dirname path); let candidate = - Filename.temp_file ~temp_dir:(Filename.dirname path) ".rewatch-write-" + Filename.temp_file ~temp_dir:(Filename.dirname path) atomic_write_prefix ".tmp" in let published = ref false in @@ -118,141 +120,12 @@ let write_file_atomic ?(ensure_parent = true) path contents = Sys.rename candidate path; published := true) -(* Copy and comparison buffers, one set per domain: allocating fresh 64 KiB - buffers for every copied or compared file was the largest single source of - allocation in a build. Neither function calls the other while it holds the - buffers. *) -let copy_buffer = Domain.DLS.new_key (fun () -> Bytes.create 65_536) -let compare_buffer = Domain.DLS.new_key (fun () -> Bytes.create 65_536) - -let copy_existing_file source destination = - let input_descriptor = open_for_reading source in - let input_channel = Unix.in_channel_of_descr input_descriptor in - Fun.protect - ~finally:(fun () -> close_in_noerr input_channel) - (fun () -> - (* The copy writes in place: replacing the file by a rename would leave - stale entries on case-insensitive virtiofs mounts (Docker on macOS) - for the compiler's lowercase .cmi lookups. A failed copy removes its - partial destination, so the next build publishes it again instead of - reading a truncated .cmi or .cmj. *) - Build_file_store.forget destination; - let output_channel = open_out_bin destination in - try - with_output_channel output_channel (fun output_channel -> - let buffer = Domain.DLS.get copy_buffer in - let rec copy () = - let count = input input_channel buffer 0 (Bytes.length buffer) in - if count > 0 then ( - output output_channel buffer 0 count; - copy ()) - in - copy ()) - with error -> - let backtrace = Printexc.get_raw_backtrace () in - (try Unix.unlink destination with Unix.Unix_error _ -> ()); - Printexc.raise_with_backtrace error backtrace) - -let copy_optional_existing_file source destination = - try copy_existing_file source destination - with Unix.Unix_error ((Unix.ENOENT | Unix.ENOTDIR), _, _) -> ( - try Unix.unlink destination - with Unix.Unix_error ((Unix.ENOENT | Unix.ENOTDIR), _, _) -> ()) - let stat_opt path = try Some (Unix.stat path) with Unix.Unix_error ((Unix.ENOENT | Unix.ENOTDIR), _, _) -> None let exists path = Option.is_some (stat_opt path) -let files_equal first second = - match stat_opt first with - | None -> false - | Some first_stat -> ( - match stat_opt second with - | None -> false - | Some second_stat -> - first_stat.Unix.st_size = second_stat.Unix.st_size - && - let first_descriptor = open_for_reading first in - let first_channel = Unix.in_channel_of_descr first_descriptor in - Fun.protect - ~finally:(fun () -> close_in_noerr first_channel) - (fun () -> - let second_descriptor = open_for_reading second in - let second_channel = Unix.in_channel_of_descr second_descriptor in - Fun.protect - ~finally:(fun () -> close_in_noerr second_channel) - (fun () -> - let first_buffer = Domain.DLS.get copy_buffer in - let second_buffer = Domain.DLS.get compare_buffer in - let rec read_chunk channel buffer offset = - if offset = Bytes.length buffer then offset - else - match - input channel buffer offset (Bytes.length buffer - offset) - with - | 0 -> offset - | count -> read_chunk channel buffer (offset + count) - in - let equal_prefix length = - let index = ref 0 in - while - !index < length - && Bytes.get first_buffer !index - = Bytes.get second_buffer !index - do - incr index - done; - !index = length - in - let rec loop () = - let first_count = read_chunk first_channel first_buffer 0 in - let second_count = read_chunk second_channel second_buffer 0 in - first_count = second_count - && (first_count = 0 || (equal_prefix first_count && loop ())) - in - loop ()))) - -let copy_file_if_different source destination = - let changed = not (files_equal source destination) in - if changed then copy_existing_file source destination; - changed - -(* Build outputs are read through [Build_file_store], which keeps what the - compiler wrote during the build, so publishing them reads nothing back from - disk. Like [copy_existing_file], a failed write removes its partial - destination. *) -let read_build_file path = - match Build_file_store.read path with - | Some contents -> contents - | None -> raise (Unix.Unix_error (Unix.ENOENT, "open", path)) - -let write_build_file ?keep path contents = - try Build_file_store.write ?keep path contents - with error -> - let backtrace = Printexc.get_raw_backtrace () in - (try Unix.unlink path with Unix.Unix_error _ -> ()); - Build_file_store.forget path; - Printexc.raise_with_backtrace error backtrace - -let copy_build_file ?keep source destination = - write_build_file ?keep destination (read_build_file source) - -let copy_optional_build_file ?keep source destination = - match Build_file_store.read source with - | Some contents -> write_build_file ?keep destination contents - | None -> ( - Build_file_store.forget destination; - try Unix.unlink destination - with Unix.Unix_error ((Unix.ENOENT | Unix.ENOTDIR), _, _) -> ()) - -let copy_build_file_if_different ?keep source destination = - let contents = read_build_file source in - let changed = Build_file_store.read destination <> Some contents in - if changed then write_build_file ?keep destination contents; - changed - let modification_time path = stat_opt path |> Option.map (fun metadata -> metadata.Unix.st_mtime) diff --git a/rewatch-ocaml/file_util.mli b/rewatch-ocaml/file_util.mli index 0ca827de253..2d499f32111 100644 --- a/rewatch-ocaml/file_util.mli +++ b/rewatch-ocaml/file_util.mli @@ -10,28 +10,13 @@ val append_file : string -> string -> unit val directory_entries : string -> string list val write_file_atomic : ?ensure_parent:bool -> string -> string -> unit -val copy_existing_file : string -> string -> unit -val copy_optional_existing_file : string -> string -> unit +(** Writes a file next to its destination and renames it into place. *) -val exists : string -> bool -val files_equal : string -> string -> bool -val copy_file_if_different : string -> string -> bool - -val read_build_file : string -> string -(** Reads a build file through [Build_file_store]. A missing file raises - [Unix.Unix_error ENOENT]. *) - -val write_build_file : ?keep:bool -> string -> string -> unit -val copy_build_file : ?keep:bool -> string -> string -> unit - -val copy_optional_build_file : ?keep:bool -> string -> string -> unit -(** Like [copy_build_file], but removes the destination when the source does - not exist. *) - -val copy_build_file_if_different : ?keep:bool -> string -> string -> bool -(** Copies unless the destination has the same contents, and tells whether it - copied. *) +val atomic_write_prefix : string +(** The name prefix of the files {!write_file_atomic} renames into place; one + left over is from a process killed while writing. *) +val exists : string -> bool val modification_time : string -> float option val remove_file : string -> unit val remove_tree : string -> unit diff --git a/rewatch-ocaml/module_graph.ml b/rewatch-ocaml/module_graph.ml index d2d5220d2e7..0b1d801ee5c 100644 --- a/rewatch-ocaml/module_graph.ml +++ b/rewatch-ocaml/module_graph.ml @@ -154,7 +154,7 @@ let resolved_dependencies ~find_module ~find_namespace_maps (node : module_node) |> List.filter (fun dependency -> dependency <> node.key) |> List.sort_uniq String.compare -let raw_dependencies ?(published_dependencies = fun _ -> None) ~build_dir +let raw_dependencies ?(published_dependencies = fun _ -> None) ~artifact_dir ~parse_failed (module_ : Source.module_) = let dependencies path = if parse_failed path then [] @@ -162,7 +162,7 @@ let raw_dependencies ?(published_dependencies = fun _ -> None) ~build_dir match published_dependencies path with | Some dependencies -> dependencies | None -> - (Ast_header.read (Filename.concat build_dir (Source.ast_path path))) + (Ast_header.read (Filename.concat artifact_dir (Source.ast_path path))) .dependencies in List.sort_uniq String.compare @@ -203,7 +203,7 @@ let initialize ~(root_config : Config.t) ~package_plans ~compile_assets let raw_dependencies = modules |> Parallel.map (fun ((package : Package_plan.t), _, module_) -> - raw_dependencies ~build_dir:package.build_dir + raw_dependencies ~artifact_dir:package.artifact_dir ~published_dependencies:(fun path -> let path = Filename.concat package.root path in (* The published headers were read before this build parsed. *) diff --git a/rewatch-ocaml/module_graph.mli b/rewatch-ocaml/module_graph.mli index 044903cfe0d..7b867904ac5 100644 --- a/rewatch-ocaml/module_graph.mli +++ b/rewatch-ocaml/module_graph.mli @@ -48,14 +48,14 @@ val resolved_dependencies : val raw_dependencies : ?published_dependencies:(string -> string list option) -> - build_dir:string -> + artifact_dir:string -> parse_failed:(string -> bool) -> Source.module_ -> string list (** The sorted module names that a module's ASTs reference, skipping the source paths whose parse failed. [published_dependencies path] gives the dependencies of [path]'s published AST, when it is known and current; - otherwise they are read from [path]'s AST in [build_dir]. *) + otherwise they are read from [path]'s AST in [artifact_dir]. *) type initialized = { nodes: module_node list; diff --git a/rewatch-ocaml/native_watcher.ml b/rewatch-ocaml/native_watcher.ml index 6f8b18ed70b..e08c2752e50 100644 --- a/rewatch-ocaml/native_watcher.ml +++ b/rewatch-ocaml/native_watcher.ml @@ -25,7 +25,7 @@ let error_message error = let is_compiler_artifact_directory path = let name = Filename.basename path in - (name = "bs" || name = "ocaml") + (name = "rescript" || name = "bs" || name = "ocaml") && Filename.basename (Filename.dirname path) = "lib" let directories_under paths = diff --git a/rewatch-ocaml/package_build.ml b/rewatch-ocaml/package_build.ml index f6c515b49ac..7358a842f20 100644 --- a/rewatch-ocaml/package_build.ml +++ b/rewatch-ocaml/package_build.ml @@ -18,8 +18,7 @@ let rec prepare_tree ~seen ~(package : Package_plan.t) ~prepared ~watch prepare_tree ~seen ~package:dependency_package ~prepared ~watch ~attempt) package.dependencies; - File_util.ensure_dir package.build_dir; - File_util.ensure_dir package.ocaml_dir; + File_util.ensure_dir package.artifact_dir; Compiler_log.initialize root; Build_attempt.mark_log_initialized attempt root; let prepared_package = diff --git a/rewatch-ocaml/package_compilation.ml b/rewatch-ocaml/package_compilation.ml index 68219535e34..b9c850c1875 100644 --- a/rewatch-ocaml/package_compilation.ml +++ b/rewatch-ocaml/package_compilation.ml @@ -6,8 +6,7 @@ let prepare ~(package : Package_plan.t) ~(prepared : Build_session.prepared) let config = package.compile_config in let build_state = prepared.build_state in let compile_assets = prepared.compile_assets in - let build_dir = package.build_dir in - let ocaml_dir = package.ocaml_dir in + let artifact_dir = package.artifact_dir in let modules = package.modules in let module_is_dirty module_ (state : Build_state.module_) = let global_key = Source.compiler_basename config module_.Source.name in @@ -75,13 +74,19 @@ let prepare ~(package : Package_plan.t) ~(prepared : Build_session.prepared) config.package_specs in let compile_process module_ ~source_kind path = - Compiler_process.compile_request ~build_dir ~config - ~common_args: - (if module_.Source.is_dev then - prepared_package.development_common_args - else prepared_package.regular_common_args) - module_ ~source_kind path - |> Compiler_process.task + let task = + Compiler_process.compile_request ~artifact_dir ~config + ~common_args: + (if module_.Source.is_dev then + prepared_package.development_common_args + else prepared_package.regular_common_args) + module_ ~source_kind path + |> Compiler_process.task + in + Process.map_result task (fun result -> + if not (Process.succeeded result) then + Compiler_process.discard_compile ~artifact_dir ~config path; + result) in let record_published_outputs ~source_kind path = match source_kind with @@ -104,7 +109,7 @@ let prepare ~(package : Package_plan.t) ~(prepared : Build_session.prepared) if Hashtbl.mem attempt.blocked_modules key then None else let cmi_path = - Filename.concat ocaml_dir + Filename.concat artifact_dir (Source.compiler_asset_basename config module_.Source.implementation ^ ".cmi") @@ -121,8 +126,7 @@ let prepare ~(package : Package_plan.t) ~(prepared : Build_session.prepared) ~compile:(fun ~source_kind path -> compile_process module_ ~source_kind path) ~publish:(fun ~source_kind path result -> - Compiler_process.publish ~build_dir ~ocaml_dir ~is_local - ~config + Compiler_process.publish ~artifact_dir ~is_local ~config ~has_interface:(Option.is_some module_.Source.interface) ~source_kind path result) ~record_published_outputs @@ -133,7 +137,7 @@ let prepare ~(package : Package_plan.t) ~(prepared : Build_session.prepared) :: Option.to_list module_.Source.interface |> List.iter (fun path -> Hashtbl.replace compile_warning_paths - (Build_artifacts.published_ast_path ~ocaml_dir path) + (Build_artifacts.ast_path ~artifact_dir path) ())) in Some (Compiler_scheduler.candidate ~key ~state ~warning_paths ~make)) @@ -156,15 +160,14 @@ let prepare ~(package : Package_plan.t) ~(prepared : Build_session.prepared) || attempt.freshness_mode = Build_attempt.Initialize_freshness then Compiler_process.namespace_task - ~runtime:prepared.compiler_context.runtime_path ~build_dir - ~ocaml_dir + ~runtime:prepared.compiler_context.runtime_path ~artifact_dir ~entry:(Config.namespace_entry config.namespace) ~package_dirty ~force:namespace_state.compile_dirty compiler_name modules |> Option.iter (fun namespace_task -> namespace_state.compile_dirty <- true; let cmi_path = - Filename.concat ocaml_dir (compiler_name ^ ".cmi") + Filename.concat artifact_dir (compiler_name ^ ".cmi") in let finish result = if not (Process.succeeded result) then @@ -178,7 +181,7 @@ let prepare ~(package : Package_plan.t) ~(prepared : Build_session.prepared) Build_state.record_published_cmi build_state ~compile_assets namespace_state ~path:cmi_path cmi_change; let cmt_path = - Filename.concat ocaml_dir (compiler_name ^ ".cmt") + Filename.concat artifact_dir (compiler_name ^ ".cmt") in Build_state.record_successful_compile ~compile_assets namespace_state ~cmt_path @@ -194,5 +197,5 @@ let prepare ~(package : Package_plan.t) ~(prepared : Build_session.prepared) Build_attempt.register_cleanup attempt (fun () -> if not watch then Hashtbl.iter - (fun path () -> File_util.remove_file path) + (fun path () -> Build_artifacts.invalidate_ast path) compile_warning_paths)) diff --git a/rewatch-ocaml/package_graph.ml b/rewatch-ocaml/package_graph.ml index b49dc26b1b5..4a402e3f364 100644 --- a/rewatch-ocaml/package_graph.ml +++ b/rewatch-ocaml/package_graph.ml @@ -120,8 +120,7 @@ let discover ~(root_config : Config.t) ~(workspace_config : Config.t) ~prod Config.with_root_options config workspace_config |> Compiler_args.with_local_warning_policy ~is_local in - let build_dir = Build_artifacts.lib_path root "bs" in - let ocaml_dir = Build_artifacts.lib_path root "ocaml" in + let artifact_dir = Build_artifacts.artifact_dir root in let source_mtimes = Hashtbl.create (List.length discovery.source_mtimes) in @@ -136,8 +135,7 @@ let discover ~(root_config : Config.t) ~(workspace_config : Config.t) ~prod is_local; config; compile_config; - build_dir; - ocaml_dir; + artifact_dir; dependencies; gentype_dependency_args = Compiler_args.gentype_dependency_args_from_paths compile_config diff --git a/rewatch-ocaml/package_parse.ml b/rewatch-ocaml/package_parse.ml index 7f7a54b88f5..f2e002ac33c 100644 --- a/rewatch-ocaml/package_parse.ml +++ b/rewatch-ocaml/package_parse.ml @@ -5,8 +5,7 @@ let run ~(package : Package_plan.t) ~(prepared : Build_session.prepared) let config = package.compile_config in let build_state = prepared.build_state in let compile_assets = prepared.compile_assets in - let build_dir = package.build_dir in - let ocaml_dir = package.ocaml_dir in + let artifact_dir = package.artifact_dir in let dirty_parse_paths = package.modules |> List.concat_map (fun (module_ : Source.module_) -> @@ -52,9 +51,7 @@ let run ~(package : Package_plan.t) ~(prepared : Build_session.prepared) List.map2 (fun path result -> (path, Build_attempt.preliminary_parse result)) parse_paths_to_run - (List.map - (fun path -> (build_dir, ocaml_dir, config, path)) - parse_paths_to_run + (List.map (fun path -> (artifact_dir, config, path)) parse_paths_to_run |> Compiler_process.run_parses ?poll:attempt.process_poll) @ (dirty_parse_paths |> List.filter_map (fun path -> @@ -66,7 +63,7 @@ let run ~(package : Package_plan.t) ~(prepared : Build_session.prepared) (fun (path, result) -> let absolute_path = Filename.concat root path in let pending_path = Platform.normalize_path_for_comparison absolute_path in - let publish_successful_parse ~published stderr = + let publish_successful_parse ~publish stderr = let stderr = if is_local then stderr else Compiler_process.retain_critical_external_warnings stderr @@ -76,22 +73,17 @@ let run ~(package : Package_plan.t) ~(prepared : Build_session.prepared) Compiler_log.append root stderr; attempt.parse_messages <- Build_attempt.Parse_warning stderr :: attempt.parse_messages); - let ast = Source.ast_path path in + let ast = Build_artifacts.ast_path ~artifact_dir path in if is_local && stderr <> "" then Build_attempt.register_cleanup attempt (fun () -> - let path = Filename.concat ocaml_dir (Filename.basename ast) in - File_util.remove_file path; + Build_artifacts.invalidate_ast ast; Compile_assets.refresh_ast compile_assets ~source:absolute_path - ~path); - let published_ast = - Build_artifacts.published_ast_path ~ocaml_dir path - in - (* A parse in this build that printed nothing published its outputs on + ~path:ast); + (* A parse in this build that printed nothing published its AST on its worker. *) - if not published then - Compiler_process.publish_parse ~build_dir ~ocaml_dir ~config path; + if publish then Compiler_process.publish_parse ~artifact_dir path; Compile_assets.refresh_ast compile_assets ~source:absolute_path - ~path:published_ast; + ~path:ast; if is_local && stderr <> "" then Build_session.mark_parse_pending attempt.session pending_path else Build_session.clear_parse_pending attempt.session pending_path @@ -106,8 +98,8 @@ let run ~(package : Package_plan.t) ~(prepared : Build_session.prepared) attempt.parse_messages <- Build_attempt.Parse_error output :: attempt.parse_messages | Build_attempt.Parsed_successfully {stderr} -> - publish_successful_parse ~published:(stderr = "") stderr + publish_successful_parse ~publish:(stderr <> "") stderr | Build_attempt.Use_existing_ast -> - publish_successful_parse ~published:false "") + publish_successful_parse ~publish:false "") parsed; dirty_modules diff --git a/rewatch-ocaml/package_plan.ml b/rewatch-ocaml/package_plan.ml index fcecad4a377..5ae15d3882a 100644 --- a/rewatch-ocaml/package_plan.ml +++ b/rewatch-ocaml/package_plan.ml @@ -10,8 +10,7 @@ type t = { is_local: bool; config: Config.t; compile_config: Config.t; - build_dir: string; - ocaml_dir: string; + artifact_dir: string; dependencies: dependency list; gentype_dependency_args: string list; modules: Source.module_ list; diff --git a/rewatch-ocaml/package_plan.mli b/rewatch-ocaml/package_plan.mli index 7d67df7ad16..83f17ea5068 100644 --- a/rewatch-ocaml/package_plan.mli +++ b/rewatch-ocaml/package_plan.mli @@ -15,8 +15,7 @@ type t = { is_local: bool; config: Config.t; compile_config: Config.t; - build_dir: string; - ocaml_dir: string; + artifact_dir: string; dependencies: dependency list; gentype_dependency_args: string list; modules: Source.module_ list; diff --git a/rewatch-ocaml/source.ml b/rewatch-ocaml/source.ml index 214b71b3106..73b7283877f 100644 --- a/rewatch-ocaml/source.ml +++ b/rewatch-ocaml/source.ml @@ -432,8 +432,10 @@ let discover_with_inventory ?(on_orphan = fun _ -> ()) ~on_missing gentype_dirs = scanned.gentype_dirs; } +(* Module names are unique within a package, so the artifact directory is flat: + src/nested/A.res and its interface parse to A.ast and A.iast. *) let ast_path path = - Filename.remove_extension path + Filename.remove_extension (Filename.basename path) ^ if Filename.extension path = ".resi" then ".iast" else ".ast" let compiler_basename config module_name = diff --git a/rewatch-ocaml/source.mli b/rewatch-ocaml/source.mli index c81748d8b92..511fadc3b81 100644 --- a/rewatch-ocaml/source.mli +++ b/rewatch-ocaml/source.mli @@ -59,5 +59,8 @@ val discover_with_inventory : discovery val ast_path : string -> string +(** The file name, without directory, of a source's AST in the artifact + directory: [A.ast] for an implementation, [A.iast] for an interface. *) + val compiler_basename : Config.t -> string -> string val compiler_asset_basename : Config.t -> string -> string diff --git a/rewatch-ocaml/source_dirs.ml b/rewatch-ocaml/source_dirs.ml index 755152de6c3..9c7032bbd58 100644 --- a/rewatch-ocaml/source_dirs.ml +++ b/rewatch-ocaml/source_dirs.ml @@ -1,21 +1,22 @@ -type scan = {build_root: string; scan_dirs: string list} - -(* Every scan includes its build root (also_scan_build_root). *) -let scan_json scan = +(* A package's artifact directory is flat, so its scan is the build root + alone: no subdirectories, and also_scan_build_root. *) +let scan_json build_root = `Assoc [ ("also_scan_build_root", `Bool true); - ("build_root", `String scan.build_root); - ("scan_dirs", `List (List.map (fun path -> `String path) scan.scan_dirs)); + ("build_root", `String build_root); + ("scan_dirs", `List []); ] -let write ~root ~dirs ~packages ~scans = - let path = File_util.path_of_parts root ["lib"; "bs"; ".sourcedirs.json"] in +let write ~root ~dirs ~packages ~build_roots = + let path = + Filename.concat (Build_artifacts.artifact_dir root) ".sourcedirs.json" + in File_util.ensure_dir (Filename.dirname path); let json = `Assoc [ - ("cmt_scan", `List (List.map scan_json scans)); + ("cmt_scan", `List (List.map scan_json build_roots)); ("dirs", `List (List.map (fun path -> `String path) dirs)); ("generated", `List []); ( "pkgs", @@ -40,8 +41,9 @@ let write_build ~(root_config : Config.t) session = |> List.iter (fun package -> if package.Package_plan.root <> root_config.root then File_util.remove_file - (File_util.path_of_parts package.root - ["lib"; "bs"; ".sourcedirs.json"])); + (Filename.concat + (Build_artifacts.artifact_dir package.root) + ".sourcedirs.json")); let local_packages = List.filter (fun package -> package.Package_plan.is_local) packages in @@ -76,16 +78,10 @@ let write_build ~(root_config : Config.t) session = |> List.of_seq |> List.sort (fun (left, _) (right, _) -> String.compare left right) in - let scans = + let build_roots = local_packages |> List.map (fun package -> - let relative_root = relative_package_root package in - let build_root = - if relative_root = "" then File_util.path_of_parts "" ["lib"; "bs"] - else File_util.path_of_parts relative_root ["lib"; "bs"] - in - {build_root; scan_dirs = source_directories package}) - |> List.sort (fun (left : scan) right -> - String.compare left.build_root right.build_root) + Build_artifacts.artifact_dir (relative_package_root package)) + |> List.sort String.compare in - write ~root:root_config.root ~dirs ~packages:package_roots ~scans + write ~root:root_config.root ~dirs ~packages:package_roots ~build_roots diff --git a/rewatch-ocaml/tests/check_command_validation.sh b/rewatch-ocaml/tests/check_command_validation.sh index b36ca1cd96b..f1a01a56bad 100755 --- a/rewatch-ocaml/tests/check_command_validation.sh +++ b/rewatch-ocaml/tests/check_command_validation.sh @@ -58,9 +58,9 @@ project="$work/project" mkdir -p "$project/src" "$work/orphan" "$work/empty" "$work/malformed" mkdir -p "$work/malformed-parent/child/src" "$work/config-directory/rescript.json" mkdir -p "$work/missing-dependency/src" -mkdir -p "$work/malformed-lock/src" "$work/malformed-lock/lib" -mkdir -p "$work/watch-lock-order/src" "$work/watch-lock-order/lib" -mkdir -p "$work/signal-lock/src" "$work/signal-lock/lib" +mkdir -p "$work/malformed-lock/src" "$work/malformed-lock/lib/rescript" +mkdir -p "$work/watch-lock-order/src" "$work/watch-lock-order/lib/rescript" +mkdir -p "$work/signal-lock/src" "$work/signal-lock/lib/rescript" mkdir -p "$work/signal-lock-owner/src" mkdir -p "$work/interface-mismatch/src" mkdir -p "$work/exotic-module/src" @@ -76,10 +76,10 @@ mkdir -p "$work/active-permission/node_modules/a" \ mkdir -p "$work/source-path-file" mkdir -p "$work/missing-runtime-package" mkdir -p "$work/clean-missing-runtime/src" \ - "$work/clean-missing-runtime/lib/bs" + "$work/clean-missing-runtime/lib/rescript" mkdir -p "$work/clean-duplicate/src/one" \ "$work/clean-duplicate/src/two" \ - "$work/clean-duplicate/lib/bs" + "$work/clean-duplicate/lib/rescript" mkdir -p "$work/missing-source-folder/src" \ "$work/missing-source-folder/node_modules/dep" mkdir -p "$work/dependency-without-sources/src" \ @@ -201,7 +201,7 @@ printf '{"name":"missing-runtime-package","sources":[]}\n' \ printf '{"name":"clean-missing-runtime","sources":["src"]}\n' \ >"$work/clean-missing-runtime/rescript.json" printf 'let value = 1\n' >"$work/clean-missing-runtime/src/A.res" -printf 'owned compiler artifact\n' >"$work/clean-missing-runtime/lib/bs/marker" +printf 'owned compiler artifact\n' >"$work/clean-missing-runtime/lib/rescript/marker" printf '%s\n' \ '{"name":"duplicate-clean","sources":{"dir":"src","subdirs":true},"package-specs":{"module":"esmodule","in-source":true}}' \ >"$work/clean-duplicate/rescript.json" @@ -209,7 +209,7 @@ printf 'let value = 1\n' >"$work/clean-duplicate/src/one/A.res" printf 'let value = 2\n' >"$work/clean-duplicate/src/two/A.res" printf 'generated\n' >"$work/clean-duplicate/src/one/A.js" printf 'generated\n' >"$work/clean-duplicate/src/two/A.js" -printf 'owned compiler artifact\n' >"$work/clean-duplicate/lib/bs/marker" +printf 'owned compiler artifact\n' >"$work/clean-duplicate/lib/rescript/marker" printf '{"name":"missing-source-folder","sources":["src"],"dependencies":["dep"]}\n' \ >"$work/missing-source-folder/rescript.json" printf 'let value = 1\n' >"$work/missing-source-folder/src/App.res" @@ -610,7 +610,7 @@ run_case compiler-args-no-project reject compiler-args "$work/orphan/A.res" run_rescript --unset RESCRIPT_RUNTIME clean "$work/clean-missing-runtime" if [ "$rescript_status" -ne 0 ] || \ - [ -e "$work/clean-missing-runtime/lib/bs/marker" ]; then + [ -e "$work/clean-missing-runtime/lib/rescript/marker" ]; then echo "clean-missing-runtime: expected clean to succeed without a runtime" >&2 dump_output exit 1 @@ -733,9 +733,9 @@ fi run_case js-post-build-nonzero reject build "$work/failed-js-post-build" js_post_build_error="js-post-build command failed for $work/failed-js-post-build/src/A.js" require_error_contains js-post-build-nonzero "$js_post_build_error" -printf 'not-a-pid' >"$work/malformed-lock/lib/build.lock" +printf 'not-a-pid' >"$work/malformed-lock/lib/rescript/build.lock" run_case build-malformed-lock reject build "$work/malformed-lock" -if [ "$(cat "$work/malformed-lock/lib/build.lock")" != not-a-pid ]; then +if [ "$(cat "$work/malformed-lock/lib/rescript/build.lock")" != not-a-pid ]; then echo "A malformed build lock with unknown ownership was replaced" >&2 exit 1 fi @@ -754,7 +754,7 @@ signal_lock_owner_pid=$! background_pids="$background_pids $signal_lock_owner_pid" wait_for_text "$work/signal-lock-owner.out" "Finished initial compilation" printf '%s' "$(lock_owner_pid "$signal_lock_owner_pid")" \ - >"$work/signal-lock/lib/build.lock" + >"$work/signal-lock/lib/rescript/build.lock" "$rescript" watch "$work/signal-lock" \ >"$work/signal-lock.out" 2>"$work/signal-lock.err" & signal_lock_watch_pid=$! @@ -782,9 +782,9 @@ fi kill -TERM "$signal_lock_owner_pid" wait "$signal_lock_owner_pid" 2>/dev/null || true checked=$((checked + 1)) -printf 'not-a-pid' >"$work/malformed-lock/lib/watch.lock" +printf 'not-a-pid' >"$work/malformed-lock/lib/rescript/watch.lock" run_case watch-malformed-lock reject watch "$work/malformed-lock" -if [ "$(cat "$work/malformed-lock/lib/watch.lock")" != not-a-pid ]; then +if [ "$(cat "$work/malformed-lock/lib/rescript/watch.lock")" != not-a-pid ]; then echo "A malformed watch lock with unknown ownership was replaced" >&2 exit 1 fi @@ -813,7 +813,7 @@ if [ -z "$native_owner_pid" ]; then exit 1 fi printf '%s' "$native_owner_pid" \ - >"$work/watch-lock-order/lib/watch.lock" + >"$work/watch-lock-order/lib/rescript/watch.lock" run_rescript watch "$work/watch-lock-order" if [ "$(classify "$rescript_status")" != reject ] || \ ! grep -F 'A ReScript build is already running' \ @@ -830,7 +830,7 @@ run_case build-interface-path-mismatch reject build \ "$work/interface-mismatch" check_output_snapshot --stderr-only build-interface-path-mismatch run_rescript build "$work/exotic-module" -mlmap="$work/exotic-module/lib/bs/Ns.mlmap" +mlmap="$work/exotic-module/lib/rescript/Ns.mlmap" if [ "$(classify "$rescript_status")" != accept ] || \ ! grep -Fx Main "$mlmap" >/dev/null || \ grep -F 'Foo-bar' "$mlmap" >/dev/null; then @@ -996,7 +996,7 @@ watch_err="$work/watch-config.err" watch_pid=$! background_pids="$background_pids $watch_pid" wait_for_file "$watch_project/src/A.js" -wait_for_text "$watch_project/lib/ocaml/.compiler.log" "#Done(" +wait_for_text "$watch_project/lib/rescript/.compiler.log" "#Done(" printf '{ invalid json\n' >"$watch_project/rescript.json" wait_for_text "$watch_err" "invalid JSON" if ! kill -0 "$watch_pid" 2>/dev/null; then @@ -1015,7 +1015,7 @@ fi printf '{"name":"watch-config","sources":["src"],"package-specs":{"module":"esmodule","in-source":true,"suffix":".mjs"}}\n' \ >"$watch_project/rescript.json" wait_for_file "$watch_project/src/A.mjs" -wait_for_file "$watch_project/lib/bs/build.ninja" +wait_for_file "$watch_project/lib/rescript/compiler-info.json" if ! terminate_and_wait "$watch_pid" "recoverable-config watcher"; then cat "$watch_out" "$watch_err" >&2 exit 1 @@ -1216,7 +1216,7 @@ if ! kill -0 "$quiet_watch_pid" 2>/dev/null; then fi printf 'let value = 3\n' >"$quiet_watch_project/src/A.res" wait_for_line_count "$quiet_watch_marker" 3 -rm "$quiet_watch_project/lib/watch.lock" +rm "$quiet_watch_project/lib/rescript/watch.lock" wait_for_exit "$quiet_watch_pid" wait "$quiet_watch_pid" if [ -s "$work/quiet-watch.out" ] || \ @@ -1246,7 +1246,7 @@ run_rescript clean "$work/clean-duplicate" if [ "$rescript_status" -ne 0 ] || \ [ -e "$work/clean-duplicate/src/one/A.js" ] || \ [ -e "$work/clean-duplicate/src/two/A.js" ] || \ - [ -e "$work/clean-duplicate/lib/bs/marker" ]; then + [ -e "$work/clean-duplicate/lib/rescript/marker" ]; then echo "clean-duplicate-modules: duplicate modules were not cleaned" >&2 dump_output exit 1 @@ -1272,8 +1272,8 @@ if $windows_posix_shell; then # remove its locks. Its external termination intentionally leaves a stale # watch lock, and a build lock if the rebuild was still finishing, so remove # those harness artifacts before checking failure paths. - rm -f "$work/missing-dependency/lib/watch.lock" \ - "$work/missing-dependency/lib/build.lock" + rm -f "$work/missing-dependency/lib/rescript/watch.lock" \ + "$work/missing-dependency/lib/rescript/build.lock" fi printf '{"name":"missing-dependency","sources":["src"],"dependencies":["absent"]}\n' \ >"$work/missing-dependency/rescript.json" @@ -1284,8 +1284,8 @@ run_case --cwd "$work/configless-dependency" \ format-configless-dependency exit2 format run_case --cwd "$work/malformed-dependency" \ format-malformed-dependency exit2 format -if [ -e "$work/missing-dependency/lib/build.lock" ] || \ - [ -e "$work/missing-dependency/lib/watch.lock" ]; then +if [ -e "$work/missing-dependency/lib/rescript/build.lock" ] || \ + [ -e "$work/missing-dependency/lib/rescript/watch.lock" ]; then echo "Dependency failures left a build or watch lock behind" >&2 exit 1 fi diff --git a/rewatch-ocaml/tests/check_config_acceptance.sh b/rewatch-ocaml/tests/check_config_acceptance.sh index ea71a575ea3..b0e3a8ed020 100755 --- a/rewatch-ocaml/tests/check_config_acceptance.sh +++ b/rewatch-ocaml/tests/check_config_acceptance.sh @@ -14,7 +14,7 @@ rescript=$(realpath "$rescript") mkdir -p "$root/tmp" work=$(mktemp -d "$root/tmp/rewatch-config-acceptance-XXXXXX") trap 'rm -rf "$work"' EXIT -mkdir -p "$work/project/src" "$work/project/node_modules/dep/lib/ocaml" \ +mkdir -p "$work/project/src" "$work/project/node_modules/dep/lib/rescript" \ "$work/project/node_modules/ppx" project=$work/project printf 'let value = 1\n' >"$project/src/A.res" diff --git a/rewatch-ocaml/tests/check_interactive_output.sh b/rewatch-ocaml/tests/check_interactive_output.sh index 4f7fbab6c59..7cda3e1ec8d 100755 --- a/rewatch-ocaml/tests/check_interactive_output.sh +++ b/rewatch-ocaml/tests/check_interactive_output.sh @@ -25,7 +25,7 @@ active_watch_transcript="" cleanup() { if [ -n "$active_script_pid" ]; then if [ -n "$active_watch_project" ]; then - rm -f "$active_watch_project/lib/watch.lock" + rm -f "$active_watch_project/lib/rescript/watch.lock" fi if ! wait_for_pid_gone "$active_script_pid" 50; then kill -TERM "$active_script_pid" 2>/dev/null || true @@ -241,7 +241,7 @@ overwrite_line_in_place() { } stop_active_watch() { - rm -f "$active_watch_project/lib/watch.lock" + rm -f "$active_watch_project/lib/rescript/watch.lock" if ! wait_for_pid_gone "$active_script_pid"; then echo "Timed out waiting for the interactive watcher to stop" >&2 if [ -f "$active_watch_transcript" ]; then diff --git a/rewatch-ocaml/tests/run.sh b/rewatch-ocaml/tests/run.sh index 5256fb5880f..4e705fd049c 100644 --- a/rewatch-ocaml/tests/run.sh +++ b/rewatch-ocaml/tests/run.sh @@ -7,6 +7,12 @@ if [ -n "${BASH_VERSION:-}" ]; then trap 'case $- in *e*) echo "run.sh: line $LINENO failed: $BASH_COMMAND" >&2 ;; esac' ERR fi +# artifacts_removed ROOT: a clean removed every artifact below ROOT and left +# lib/rescript empty, or with the lock files of a running watcher. +artifacts_removed() { + [ ! -d "$1/lib/rescript" ] || [ -z "$(ls -A "$1/lib/rescript")" ] +} + port="$1" port_directory=$(CDPATH= cd -- "$(dirname "$port")" && pwd) port="$port_directory/$(basename "$port")" @@ -49,7 +55,7 @@ done unlinked_dependency="$work/unlinked-dependency" mkdir -p "$unlinked_dependency/src" \ "$unlinked_dependency/packages/dep/src" \ - "$unlinked_dependency/packages/dep/lib/ocaml" + "$unlinked_dependency/packages/dep/lib/rescript" printf '%s\n' \ '{"name":"unlinked-root","sources":"src","dependencies":["dep"]}' \ >"$unlinked_dependency/rescript.json" @@ -60,7 +66,7 @@ printf 'let value = 1\n' >"$unlinked_dependency/packages/dep/src/Dep.res" printf 'export const value = 1;\n' \ >"$unlinked_dependency/packages/dep/src/Dep.js" printf 'owned outside the resolved graph\n' \ - >"$unlinked_dependency/packages/dep/lib/ocaml/marker" + >"$unlinked_dependency/packages/dep/lib/rescript/marker" mkdir -p "$work/standalone-output/src" \ "$work/standalone-output/node_modules" cp -R "$root/rewatch-ocaml/tests/shared-dep" \ @@ -476,7 +482,7 @@ done # bsc.exe shipped next to the executable. "$port" build "$packaged_basic" >"$packaged_basic/build.log" test -f "$packaged_basic/src/A.mjs" -COMPILER_INFO=$(native_path "$packaged_basic/lib/bs/compiler-info.json") \ +COMPILER_INFO=$(native_path "$packaged_basic/lib/rescript/compiler-info.json") \ EXPECTED_BSC=$(native_path "$port_directory/bsc.exe") node -e ' const fs = require("node:fs"); const path = require("node:path"); @@ -697,7 +703,7 @@ stop_watch() { project=$1 pid=$2 if $windows_posix_shell; then - remove_file_with_retry "$project/lib/watch.lock" + remove_file_with_retry "$project/lib/rescript/watch.lock" else kill -TERM "$pid" fi @@ -771,11 +777,10 @@ grep -F "The file listed above needs formatting" \ grep -F "Formatting check failed" "$work/format-check.err" >/dev/null "$port" build "$no_bin_annot" >/dev/null -test -f "$no_bin_annot/lib/bs/src/NoBinAnnot.cmi" -test -f "$no_bin_annot/lib/bs/src/NoBinAnnot.cmj" +test -f "$no_bin_annot/lib/rescript/NoBinAnnot.cmi" +test -f "$no_bin_annot/lib/rescript/NoBinAnnot.cmj" test -f "$no_bin_annot/src/NoBinAnnot.js" -test ! -e "$no_bin_annot/lib/bs/src/NoBinAnnot.cmt" -test ! -e "$no_bin_annot/lib/ocaml/NoBinAnnot.cmt" +test ! -e "$no_bin_annot/lib/rescript/NoBinAnnot.cmt" if (cd "$basic/src" && "$port" format --check) \ >"$work/format-nested.out" 2>"$work/format-nested.err"; then @@ -821,8 +826,8 @@ printf '%s\n' \ "$port" build "$monorepo/packages/consumer" test -f "$monorepo/packages/consumer/src/Consumer.js" test -f "$monorepo/packages/dep/src/Dep.js" -test ! -f "$monorepo/packages/dep/lib/bs/.sourcedirs.json" -node - "$monorepo/packages/consumer/lib/bs/.sourcedirs.json" \ +test ! -f "$monorepo/packages/dep/lib/rescript/.sourcedirs.json" +node - "$monorepo/packages/consumer/lib/rescript/.sourcedirs.json" \ "$monorepo/packages/dep" <<'NODE' const fs = require("fs"); const [sourceDirsPath, dependencyPath] = process.argv.slice(2); @@ -831,7 +836,7 @@ const normalize = value => value.replaceAll("\\", "/"); if (JSON.stringify(sourceDirs.dirs) !== JSON.stringify(["src"])) { throw new Error(`unexpected direct-package source dirs: ${JSON.stringify(sourceDirs.dirs)}`); } -if (sourceDirs.cmt_scan.length !== 1 || normalize(sourceDirs.cmt_scan[0].build_root) !== "lib/bs") { +if (sourceDirs.cmt_scan.length !== 1 || normalize(sourceDirs.cmt_scan[0].build_root) !== "lib/rescript") { throw new Error(`unexpected direct-package scan plan: ${JSON.stringify(sourceDirs.cmt_scan)}`); } const packages = new Map(sourceDirs.pkgs); @@ -852,17 +857,19 @@ test -f "$basic/src/Authored.js" test ! -f "$basic/src/B.mjs" rm -rf "$basic/lib" rm -f "$basic/src/A.mjs" +# A lib/bs of an earlier version is removed by the first build, and does not +# make it remove authored JavaScript. mkdir -p "$basic/lib/bs/other" touch "$basic/lib/bs/other/Authored.js" "$port" build --after-build 'test -f src/A.mjs' "$basic" -test -f "$basic/lib/bs/build.ninja" +test ! -d "$basic/lib/bs" test -f "$basic/src/A.mjs" test -f "$basic/src/Authored.js" test -f "$basic/src/B.mjs" test -f "$basic/src/WithInterface.mjs" -test -f "$basic/lib/ocaml/A.cmi" -test -f "$basic/lib/ocaml/WithInterface.cmti" +test -f "$basic/lib/rescript/A.cmi" +test -f "$basic/lib/rescript/WithInterface.cmti" printf '\nlet streamedAfterBuild = 1\n' >>"$basic/src/A.res" after_build_release="$basic/after-build-release" @@ -887,8 +894,7 @@ if "$port" build "$cleanup_lifecycle" >/dev/null 2>&1; then echo "build after a depended-on rename unexpectedly succeeded" >&2 exit 1 fi -test ! -f "$cleanup_lifecycle/lib/bs/src/A.cmi" -test ! -f "$cleanup_lifecycle/lib/ocaml/A.cmi" +test ! -f "$cleanup_lifecycle/lib/rescript/A.cmi" # Destructive cleanup must invalidate consumers before a later deletion error # can abort the command and erase the removed module's AST provenance. @@ -990,8 +996,7 @@ rm "$basic/src/lower.resi" printf 'let value = Lower.hidden\n' > "$basic/src/LowerConsumer.res" "$port" build "$basic" >/dev/null grep 'hidden' "$basic/src/LowerConsumer.mjs" >/dev/null -test ! -f "$basic/lib/ocaml/lower.cmti" -test ! -f "$basic/lib/bs/src/lower.cmti" +test ! -f "$basic/lib/rescript/lower.cmti" "$port" clean "$basic" test ! -f "$basic/src/A.mjs" @@ -1009,8 +1014,8 @@ if ! wait_for_file "$watch_basic/src/A.mjs"; then exit 1 fi wait_for_initial_build "$watch_basic/watch.log" -test -f "$watch_basic/lib/watch.lock" -grep '^[0-9][0-9]*$' "$watch_basic/lib/watch.lock" >/dev/null +test -f "$watch_basic/lib/rescript/watch.lock" +grep '^[0-9][0-9]*$' "$watch_basic/lib/rescript/watch.lock" >/dev/null printf '\nlet watchedValue = 1\n' >> "$watch_basic/src/B.res" if ! wait_for_text "$watch_basic/src/B.mjs" 'watchedValue'; then kill -TERM "$watch_pid" 2>/dev/null || true @@ -1089,11 +1094,11 @@ fi lock_exit_pid=$! background_pids="$background_pids $lock_exit_pid" wait_for_initial_build "$missing_nested_source/lock-exit.log" -rm -f "$missing_nested_source/lib/watch.lock" +rm -f "$missing_nested_source/lib/rescript/watch.lock" wait "$lock_exit_pid" 2>/dev/null || true if ! grep -F 'Exiting... (lockfile removed)' \ "$missing_nested_source/lock-exit.log" >/dev/null; then - echo "watch did not report its exit after lib/watch.lock was removed" >&2 + echo "watch did not report its exit after lib/rescript/watch.lock was removed" >&2 cat "$missing_nested_source/lock-exit.log" >&2 exit 1 fi @@ -1298,7 +1303,7 @@ fi >"$parse_publication/watch.log" 2>&1 & parse_publication_pid=$! background_pids="$background_pids $parse_publication_pid" -parse_destination="$parse_publication/lib/ocaml/A.res" +parse_destination="$parse_publication/lib/rescript/A.ast" if ! wait_for_text "$parse_publication/watch.log" \ 'Finished initial compilation' \ || ! wait_for_file "$parse_destination"; then @@ -1336,7 +1341,7 @@ wait "$parse_publication_pid" 2>/dev/null || true >"$multi_package_pending/watch.log" 2>&1 & multi_package_pending_pid=$! background_pids="$background_pids $multi_package_pending_pid" -dep1_destination="$multi_package_pending/packages/dep1/lib/ocaml/A.res" +dep1_destination="$multi_package_pending/packages/dep1/lib/rescript/A.ast" if ! wait_for_text "$multi_package_pending/watch.log" \ 'Finished initial compilation' \ || ! wait_for_file "$dep1_destination"; then @@ -1367,7 +1372,7 @@ wait "$multi_package_pending_pid" 2>/dev/null || true >"$full_watch_recovery/watch.log" 2>&1 & full_watch_recovery_pid=$! background_pids="$background_pids $full_watch_recovery_pid" -full_watch_destination="$full_watch_recovery/lib/ocaml/C.res" +full_watch_destination="$full_watch_recovery/lib/rescript/C.ast" if ! wait_for_text "$full_watch_recovery/watch.log" \ 'Finished initial compilation' \ || ! wait_for_file "$full_watch_destination"; then @@ -1413,7 +1418,7 @@ if ! grep 'Compiled 2 modules' "$deletion_retry/retry.log" >/dev/null; then fi "$port" build "$namespace_repair" >/dev/null -namespace_repair_destination="$namespace_repair/packages/dep/lib/ocaml/Ns.cmj" +namespace_repair_destination="$namespace_repair/packages/dep/lib/rescript/Ns.cmj" obstruct_file_with_directory "$namespace_repair_destination" "$port" watch "$namespace_repair" >"$namespace_repair/watch.log" 2>&1 & namespace_repair_pid=$! @@ -1471,7 +1476,7 @@ wait "$retained_cycle_pid" 2>/dev/null || true # Initial watch recovery must retain freshness work discovered alongside an # unrelated parse failure. "$port" build "$initial_failure_freshness" >/dev/null -rm "$initial_failure_freshness/lib/ocaml/A.cmi" +rm "$initial_failure_freshness/lib/rescript/A.cmi" printf 'let other =\n' >"$initial_failure_freshness/src/B.res" "$port" watch "$initial_failure_freshness" \ >"$initial_failure_freshness/watch.log" 2>&1 & @@ -1483,7 +1488,7 @@ if ! wait_for_text "$initial_failure_freshness/watch.log" \ exit 1 fi printf 'let other = 2\n' >"$initial_failure_freshness/src/B.res" -if ! wait_for_file "$initial_failure_freshness/lib/ocaml/A.cmi"; then +if ! wait_for_file "$initial_failure_freshness/lib/rescript/A.cmi"; then cat "$initial_failure_freshness/watch.log" >&2 echo "initial parse recovery forgot missing compile artifacts" >&2 exit 1 @@ -1513,13 +1518,13 @@ grep -F "Namespace SharedNs is provided by both" \ tr '\\' '/' <"$external_namespace/build.log" | \ grep -F 'store/ns-one' >/dev/null mkdir -p \ - "$duplicate_selection/node_modules/a/node_modules/shared/lib/ocaml" + "$duplicate_selection/node_modules/a/node_modules/shared/lib/rescript" printf 'preserve nested duplicate\n' \ - >"$duplicate_selection/node_modules/a/node_modules/shared/lib/ocaml/marker" + >"$duplicate_selection/node_modules/a/node_modules/shared/lib/rescript/marker" "$port" clean "$duplicate_selection" >/dev/null test ! -f "$duplicate_selection/node_modules/shared/src/Shared.mjs" test -f \ - "$duplicate_selection/node_modules/a/node_modules/shared/lib/ocaml/marker" + "$duplicate_selection/node_modules/a/node_modules/shared/lib/rescript/marker" "$port" watch "$duplicate_selection" \ >"$duplicate_selection/watch.log" 2>&1 & duplicate_selection_pid=$! @@ -1610,7 +1615,7 @@ if ! $windows_posix_shell; then exit 1 fi wait_for_initial_build "$exit_watch_log" - printf '%s' "$lock_holder_pid" >"$warning_replay/lib/build.lock" + printf '%s' "$lock_holder_pid" >"$warning_replay/lib/rescript/build.lock" exit_started=$(date +%s) kill -TERM "$exit_watch_pid" set +e @@ -1621,12 +1626,12 @@ if ! $windows_posix_shell; then echo "watch exit waited ${exit_seconds}s for another build's lock" >&2 exit 1 fi - test "$(cat "$warning_replay/lib/build.lock")" = "$lock_holder_pid" + test "$(cat "$warning_replay/lib/rescript/build.lock")" = "$lock_holder_pid" kill "$lock_holder_pid" - rm "$warning_replay/lib/build.lock" + rm "$warning_replay/lib/rescript/build.lock" fi stop_watch "$watch_basic" "$watch_pid" -test ! -f "$watch_basic/lib/watch.lock" +test ! -f "$watch_basic/lib/rescript/watch.lock" # Watch startup shares normal build initialization, so deleting a public output # between sessions must dirty its module even when compiler artifacts are current. @@ -1640,7 +1645,7 @@ if ! wait_for_file "$watch_basic/src/A.js"; then fi wait_for_initial_build "$watch_basic/restart.log" stop_watch "$watch_basic" "$watch_restart_pid" -test ! -f "$watch_basic/lib/watch.lock" +test ! -f "$watch_basic/lib/rescript/watch.lock" if ! $windows_posix_shell; then # One-shot builds must unwind through the same process and lock owners when @@ -1688,7 +1693,7 @@ for hook_signal in TERM:143 HUP:129 QUIT:131; do echo "js-post-build hook survived $signal_name of the build" >&2 exit 1 fi - test ! -f "$hook_build/lib/build.lock" + test ! -f "$hook_build/lib/rescript/build.lock" done fi @@ -1724,7 +1729,7 @@ if ! wait "$lock_second_pid"; then exit 1 fi test -f "$second_interrupt/src/Slow.js" -test ! -f "$second_interrupt/lib/build.lock" +test ! -f "$second_interrupt/lib/rescript/build.lock" # A stop waits for the modules compiling in-process, and a repeated signal # does not cut it short: the npm launcher forwards the Ctrl-C the terminal @@ -1757,7 +1762,7 @@ if ! $windows_posix_shell; then second_interrupt_status=$? set -e if [ "$second_interrupt_status" -ne 130 ] || \ - [ -e "$second_interrupt/lib/build.lock" ] || \ + [ -e "$second_interrupt/lib/rescript/build.lock" ] || \ [ -n "$(ls "$second_interrupt/tmp")" ]; then cat "$second_interrupt/build.log" >&2 ls "$second_interrupt/tmp" >&2 @@ -1849,7 +1854,7 @@ if ! $windows_posix_shell; then interrupt_build_status=$? set -e if [ "$interrupt_build_status" -ne "$expected_status" ] || \ - [ -e "$interrupt_build/lib/build.lock" ] || \ + [ -e "$interrupt_build/lib/rescript/build.lock" ] || \ [ -e "$interrupt_build/src/Dependent.js" ]; then cat "$interrupt_build/build.log" >&2 echo "$signal_name during compiler work: status $interrupt_build_status, expected $expected_status without a lock or further compiles" >&2 @@ -1869,7 +1874,7 @@ if ! wait_for_text "$lock_interrupt/watch.log" 'compile dirty: Slow'; then echo "large module did not reach the compiler" >&2 exit 1 fi -remove_file_with_retry "$lock_interrupt/lib/watch.lock" +remove_file_with_retry "$lock_interrupt/lib/rescript/watch.lock" if ! wait_for_pid_gone "$lock_interrupt_pid" 600; then echo "watcher did not stop during compiler work after watch.lock removal" >&2 exit 1 @@ -1904,7 +1909,7 @@ if ! wait_for_text "$atomic_save/src/Slow.js" 'value = 3' 1 1200; then echo "an atomic save during a rebuild was not built" >&2 exit 1 fi -remove_file_with_retry "$atomic_save/lib/watch.lock" +remove_file_with_retry "$atomic_save/lib/rescript/watch.lock" wait "$atomic_save_pid" 2>/dev/null || true # A failed parse stays pending until the source parses: an unrelated edit @@ -1952,7 +1957,7 @@ fi grep 'value = 1' "$retained_parse/src/A.js" >/dev/null printf 'let value = 2\n' >"$retained_parse/src/A.res" wait_for_text "$retained_parse/src/A.js" 'value = 2' -remove_file_with_retry "$retained_parse/lib/watch.lock" +remove_file_with_retry "$retained_parse/lib/rescript/watch.lock" wait "$retained_parse_pid" 2>/dev/null || true # A damaged published AST, such as one cut short by a killed build, makes its @@ -1966,15 +1971,15 @@ printf 'let value = A.value + 1\n' >"$damaged_ast/src/B.res" "$port" build "$damaged_ast" >/dev/null for damage in empty garbled; do case $damage in - empty) : >"$damaged_ast/lib/ocaml/A.ast" ;; - garbled) printf '\377\377\377\377' >"$damaged_ast/lib/ocaml/A.ast" ;; + empty) : >"$damaged_ast/lib/rescript/A.ast" ;; + garbled) printf '\377\377\377\377' >"$damaged_ast/lib/rescript/A.ast" ;; esac if ! "$port" build "$damaged_ast" >"$damaged_ast/$damage.log" 2>&1; then cat "$damaged_ast/$damage.log" >&2 echo "a build failed after an $damage published AST" >&2 exit 1 fi - test -s "$damaged_ast/lib/ocaml/A.ast" + test -s "$damaged_ast/lib/rescript/A.ast" test -f "$damaged_ast/src/B.js" done @@ -1990,7 +1995,7 @@ test ! -f "$feature_dependencies/packages/dep-empty/optional/EmptyOptional.js" >"$feature_dependencies/watch.log" 2>&1 & feature_dependencies_pid=$! background_pids="$background_pids $feature_dependencies_pid" -if ! wait_for_file "$feature_dependencies/lib/watch.lock"; then +if ! wait_for_file "$feature_dependencies/lib/rescript/watch.lock"; then cat "$feature_dependencies/watch.log" >&2 exit 1 fi @@ -2018,7 +2023,7 @@ if "$port" clean "$unlinked_dependency" \ fi grep -q "Could not resolve dependency dep" "$unlinked_dependency/clean.log" test -f "$unlinked_dependency/packages/dep/src/Dep.js" -test -f "$unlinked_dependency/packages/dep/lib/ocaml/marker" +test -f "$unlinked_dependency/packages/dep/lib/rescript/marker" "$port" clean "$feature_dependencies" "$port" build --prod "$feature_dependencies" @@ -2090,8 +2095,8 @@ grep 'from "dep/lib/es6/src/Dep.mjs"' "$standalone_output/lib/es6/src/Main.mjs" >/dev/null test ! -f "$standalone_output/node_modules/dep/src/Dep.js" "$port" clean "$standalone_output" -test ! -d "$standalone_output/lib/bs" -test ! -d "$standalone_output/node_modules/dep/lib/bs" +artifacts_removed "$standalone_output" +artifacts_removed "$standalone_output/node_modules/dep" test ! -f "$standalone_output/node_modules/dep/lib/es6/src/Dep.mjs" mkdir -p "$external_boundary/project/node_modules" @@ -2220,7 +2225,7 @@ test ! -f "$out_of_source/lib/es6/src/Main.js" namespace_call_log="$namespace/compiler-calls.log" REWATCH_COMPILER_CALL_LOG="$(native_path "$namespace_call_log")" \ "$port" build "$namespace" -test -f "$namespace/lib/ocaml/A-Widget.cmi" +test -f "$namespace/lib/rescript/A-Widget.cmi" test -f "$namespace/src/B.js" : > "$namespace_call_log" REWATCH_COMPILER_CALL_LOG="$(native_path "$namespace_call_log")" \ @@ -2265,8 +2270,8 @@ fi "$port" build "$namespace_entry" test -f "$namespace_entry/src/Entry.mjs" -test -f "$namespace_entry/lib/ocaml/Entry.cmi" -test -f "$namespace_entry/lib/ocaml/Entry_alias-@EntryNamespace.cmi" +test -f "$namespace_entry/lib/rescript/Entry.cmi" +test -f "$namespace_entry/lib/rescript/Entry_alias-@EntryNamespace.cmi" "$port" build "$qualified_namespace" test -f "$qualified_namespace/src/Extent.js" @@ -2284,7 +2289,7 @@ grep 'namespace-two' "$namespace_collision/output.log" >/dev/null "$port" build "$source_map" test -f "$source_map/src/Main.js.map" -test -f "$source_map/lib/bs/compiler-info.json" +test -f "$source_map/lib/rescript/compiler-info.json" "$port" build "$source_map" >"$source_map/unchanged.log" grep 'Compiled 0 modules' "$source_map/unchanged.log" >/dev/null sed 's/"mode": "linked"/"mode": "hidden"/' "$source_map/rescript.json" \ @@ -2303,16 +2308,16 @@ test -f "$monorepo/src/Root.js" test -f "$monorepo/packages/consumer/src/Consumer.js" test -f "$monorepo/packages/dep/src/Dep.js" "$port" clean "$monorepo" -test ! -d "$monorepo/lib/ocaml" +artifacts_removed "$monorepo" # The consumer was also built directly above. A workspace clean still removes # every member's artifacts: outputs do not depend on which build ran first. -test ! -d "$monorepo/packages/consumer/lib/ocaml" -test ! -d "$monorepo/packages/dep/lib/ocaml" +artifacts_removed "$monorepo/packages/consumer" +artifacts_removed "$monorepo/packages/dep" "$port" build "$monorepo/packages/consumer" -test -d "$monorepo/packages/dep/lib/ocaml" +test -f "$monorepo/packages/dep/lib/rescript/Dep.cmj" "$port" clean "$monorepo/packages/consumer" -test ! -d "$monorepo/packages/consumer/lib/ocaml" -test ! -d "$monorepo/packages/dep/lib/ocaml" +artifacts_removed "$monorepo/packages/consumer" +artifacts_removed "$monorepo/packages/dep" "$port" build --features all "$features" test -f "$features/native/Native.js" @@ -2332,10 +2337,46 @@ if "$port" build "$failure" >"$failure/output.log" 2>&1; then echo "invalid build unexpectedly succeeded" >&2 exit 1 fi -test -f "$failure/lib/bs/build.ninja" grep "expected to have type" "$failure/output.log" >/dev/null -test ! -f "$root/lib/build.lock" +test ! -f "$root/lib/rescript/build.lock" + +# A failed first build records the compiler, so the next build does not clean +# the package again. +if "$port" build "$failure" >"$failure/retry.log" 2>&1; then + echo "invalid build unexpectedly succeeded on retry" >&2 + exit 1 +fi +if grep "Cleaned previous build" "$failure/retry.log" >/dev/null; then + echo "a build after a failed first build cleaned the package" >&2 + cat "$failure/retry.log" >&2 + exit 1 +fi cp "$failure/Broken.fixed" "$failure/src/Broken.res" "$port" build "$failure" test -f "$failure/src/Broken.js" + +# Sources dated to the epoch, as archives built with SOURCE_DATE_EPOCH=0 have +# them: the AST of a module that failed to compile is still parsed again. +epoch_sources="$work/epoch-sources" +mkdir -p "$epoch_sources/src" +printf '%s\n' \ + '{"name":"epoch-sources","sources":"src","package-specs":{"module":"esmodule","in-source":true,"suffix":".mjs"}}' \ + >"$epoch_sources/rescript.json" +printf 'let x = 1\n' >"$epoch_sources/src/A.res" +printf 'let y = A.x + 1\n' >"$epoch_sources/src/B.res" +date_to_epoch() { + node -e 'for (const file of process.argv.slice(1)) require("fs").utimesSync(file, 0, 0)' \ + "$(native_path "$1")" +} +date_to_epoch "$epoch_sources/src/A.res" +date_to_epoch "$epoch_sources/src/B.res" +"$port" build "$epoch_sources" +printf 'let x = "s"\n' >"$epoch_sources/src/A.res" +for attempt in first second; do + if "$port" build "$epoch_sources" >"$epoch_sources/$attempt.log" 2>&1; then + echo "the $attempt build after B's dependency changed type succeeded" >&2 + cat "$epoch_sources/$attempt.log" >&2 + exit 1 + fi +done diff --git a/rewatch-ocaml/tests/snapshots/config_acceptance/arguments.txt b/rewatch-ocaml/tests/snapshots/config_acceptance/arguments.txt index c19664747c1..d11d6ee4ae2 100644 --- a/rewatch-ocaml/tests/snapshots/config_acceptance/arguments.txt +++ b/rewatch-ocaml/tests/snapshots/config_acceptance/arguments.txt @@ -1,504 +1,504 @@ sources/omitted - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res sources/null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res sources/shorthand - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res sources/empty-list - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res sources/qualified - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res sources/empty-dir - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res sources/subdirs-null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res sources/subdirs-false - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res sources/subdirs-true - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res sources/subdirs-empty - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res sources/subdirs-shorthand - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res sources/subdirs-qualified - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res sources/type-null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res sources/type-dev - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res sources/type-custom - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res sources/feature-null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res sources/feature-string - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res sources/unknown-qualified-field - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res dependencies/omitted - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res dependencies/null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res dependencies/empty - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res dependencies/shorthand - compiler: -I ../ocaml -runtime-path -I /node_modules/dep/lib/ocaml -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -I /node_modules/dep/lib/rescript -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res dependencies/qualified - compiler: -I ../ocaml -runtime-path -I /node_modules/dep/lib/ocaml -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -I /node_modules/dep/lib/rescript -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res dependencies/features-null - compiler: -I ../ocaml -runtime-path -I /node_modules/dep/lib/ocaml -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -I /node_modules/dep/lib/rescript -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res dependencies/features-empty - compiler: -I ../ocaml -runtime-path -I /node_modules/dep/lib/ocaml -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -I /node_modules/dep/lib/rescript -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res dependencies/features-list - compiler: -I ../ocaml -runtime-path -I /node_modules/dep/lib/ocaml -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -I /node_modules/dep/lib/rescript -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res dependencies/empty-name - compiler: -I ../ocaml -runtime-path -I /node_modules/lib/ocaml -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -I /node_modules/lib/rescript -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res dependencies/unknown-qualified-field - compiler: -I ../ocaml -runtime-path -I /node_modules/dep/lib/ocaml -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -I /node_modules/dep/lib/rescript -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res dependencies/legacy-alias - compiler: -I ../ocaml -runtime-path -I /node_modules/dep/lib/ocaml -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -I /node_modules/dep/lib/rescript -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res dependencies/dev - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res dependencies/legacy-dev-alias - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res features/omitted - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res features/null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res features/empty - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res features/leaf - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res features/transitive - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res allowed-dependents/omitted - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res allowed-dependents/null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res allowed-dependents/empty - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res allowed-dependents/list - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res package-specs/omitted - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res package-specs/null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res package-specs/esmodule - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res package-specs/commonjs - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output commonjs:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output commonjs:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res package-specs/es6-alias - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res package-specs/cjs-alias - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output commonjs:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output commonjs:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res package-specs/empty-list - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res package-specs/in-source-false - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:lib/es6/src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:lib/es6/src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res package-specs/null-suffix - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res package-specs/explicit-suffix - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.mjs src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.mjs A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res package-specs/empty-suffix - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src: src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src: A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res package-specs/top-level-suffix - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.mjs src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.mjs A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res package-specs/same-suffix-different-location - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.mjs -bs-package-output commonjs:lib/js/src:.mjs src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.mjs -bs-package-output commonjs:lib/js/src:.mjs A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res package-specs/unknown-field - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/omitted - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/empty - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/version-null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/version-four - compiler: -I ../ocaml -runtime-path -bs-jsx 4 -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -bs-jsx 4 -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-jsx 4 -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -bs-jsx 4 -absname -bs-ast -o A.ast ../../src/A.res jsx/module-null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/module-react-constructor - compiler: -I ../ocaml -runtime-path -bs-jsx-module React -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -bs-jsx-module React -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-jsx-module React -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -bs-jsx-module React -absname -bs-ast -o A.ast ../../src/A.res jsx/module-react-lowercase - compiler: -I ../ocaml -runtime-path -bs-jsx-module react -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -bs-jsx-module react -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-jsx-module react -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -bs-jsx-module react -absname -bs-ast -o A.ast ../../src/A.res jsx/module-custom - compiler: -I ../ocaml -runtime-path -bs-jsx-module Voby.JSX -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -bs-jsx-module Voby.JSX -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-jsx-module Voby.JSX -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -bs-jsx-module Voby.JSX -absname -bs-ast -o A.ast ../../src/A.res jsx/mode-null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/mode-classic - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/mode-automatic - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/v3-dependencies-null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/v3-dependencies - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/preserve-null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/preserve-false - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/preserve-true - compiler: -I ../ocaml -runtime-path -bs-jsx-preserve -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -bs-jsx-preserve -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-jsx-preserve -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -bs-jsx-preserve -absname -bs-ast -o A.ast ../../src/A.res jsx/unknown-field - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/unknown-mode - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/boolean-mode - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/string-v3-dependencies - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/mixed-v3-dependencies - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/duplicate-mode - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res jsx/duplicate-v3-dependencies - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res source-map/omitted - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res source-map/null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res source-map/disabled - compiler: -I ../ocaml -runtime-path -bs-source-map false -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-source-map false -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res source-map/linked-always - compiler: -I ../ocaml -runtime-path -bs-source-map linked -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-source-map linked -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res source-map/inline-dev - compiler: -I ../ocaml -runtime-path -bs-source-map false -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-source-map false -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res source-map/hidden - compiler: -I ../ocaml -runtime-path -bs-source-map hidden -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-source-map hidden -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res source-map/null-options - compiler: -I ../ocaml -runtime-path -bs-source-map linked -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-source-map linked -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res source-map/options - compiler: -I ../ocaml -runtime-path -bs-source-map linked -bs-source-map-sources-content true -bs-source-map-root /source -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-source-map linked -bs-source-map-sources-content true -bs-source-map-root /source -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res source-map/unknown-field - compiler: -I ../ocaml -runtime-path -bs-source-map linked -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-source-map linked -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res post-build/omitted - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res post-build/null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res post-build/command - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res post-build/empty-command - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res post-build/unknown-field - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res top-level/minimal - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res top-level/empty-name - compiler: -I ../ocaml -runtime-path -bs-package-name -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res top-level/unknown-field - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res top-level/editor-arbitrary - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res top-level/reanalyze-arbitrary - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res top-level/internal-path-string - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res top-level/internal-path-null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res top-level/internal-path-boolean - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res warnings/omitted - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res warnings/null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res warnings/empty - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res warnings/number - compiler: -I ../ocaml -runtime-path -w +A -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -w +A -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -w +A -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -w +A -absname -bs-ast -o A.ast ../../src/A.res warnings/error-true - compiler: -I ../ocaml -runtime-path -warn-error A -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -warn-error A -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -warn-error A -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -warn-error A -absname -bs-ast -o A.ast ../../src/A.res warnings/error-false - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res warnings/error-string - compiler: -I ../ocaml -runtime-path -warn-error +101 -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -warn-error +101 -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -warn-error +101 -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -warn-error +101 -absname -bs-ast -o A.ast ../../src/A.res warnings/null-fields - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res warnings/unknown-field - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res compiler-flags/omitted - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res compiler-flags/null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res compiler-flags/empty - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res compiler-flags/string-entry - compiler: -I ../ocaml -runtime-path -open Belt -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -open Belt -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -open Belt -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -open Belt -absname -bs-ast -o A.ast ../../src/A.res compiler-flags/array-entry - compiler: -I ../ocaml -runtime-path -open Belt -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -open Belt -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -open Belt -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -open Belt -absname -bs-ast -o A.ast ../../src/A.res compiler-flags/mixed-entries - compiler: -I ../ocaml -runtime-path -w +A -open Belt -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -w +A -open Belt -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -w +A -open Belt -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -w +A -open Belt -absname -bs-ast -o A.ast ../../src/A.res compiler-flags/empty-array-entry - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res compiler-flags/legacy-alias - compiler: -I ../ocaml -runtime-path -open Belt -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -open Belt -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -open Belt -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -open Belt -absname -bs-ast -o A.ast ../../src/A.res ppx-flags/omitted - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res ppx-flags/null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res ppx-flags/empty - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res ppx-flags/package-entry - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -ppx /node_modules/ppx -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -ppx /node_modules/ppx -absname -bs-ast -o A.ast ../../src/A.res ppx-flags/array-entry - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -ppx /node_modules/ppx --flag -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -ppx /node_modules/ppx --flag -absname -bs-ast -o A.ast ../../src/A.res ppx-flags/empty-array-entry - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res namespace/omitted - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res namespace/null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res namespace/false - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res namespace/true - compiler: -bs-ns ScopeConfigShape -I ../ocaml -runtime-path -bs-package-name scope/config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -bs-ns ScopeConfigShape -I . -runtime-path -bs-package-name scope/config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res namespace/string-true - compiler: -bs-ns ScopeConfigShape -I ../ocaml -runtime-path -bs-package-name scope/config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -bs-ns ScopeConfigShape -I . -runtime-path -bs-package-name scope/config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res namespace/custom - compiler: -bs-ns CustomName -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -bs-ns CustomName -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res namespace/scoped-package - compiler: -bs-ns ScopeMyPkg -I ../ocaml -runtime-path -bs-package-name @scope/my-pkg -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -bs-ns ScopeMyPkg -I . -runtime-path -bs-package-name @scope/my-pkg -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res namespace/underscore-without-namespace - compiler: -I ../ocaml -runtime-path -bs-package-name _ -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name _ -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res namespace/entry - compiler: -bs-ns @ConfigShape -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -bs-ns @ConfigShape -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res namespace/null-entry - compiler: -bs-ns ConfigShape -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -bs-ns ConfigShape -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res compiler-flags/whitespace-normalization - compiler: -I ../ocaml -runtime-path -w +A -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -w +A -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -w +A -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -w +A -absname -bs-ast -o A.ast ../../src/A.res experimental/omitted - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res experimental/null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res experimental/empty - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res experimental/enabled - compiler: -I ../ocaml -runtime-path -enable-experimental LetUnwrap -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -enable-experimental LetUnwrap -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -enable-experimental LetUnwrap -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -enable-experimental LetUnwrap -absname -bs-ast -o A.ast ../../src/A.res experimental/disabled - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/omitted - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/null - compiler: -I ../ocaml -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/empty - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/module-null - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/module-esmodule - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-module esmodule -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-module esmodule -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/module-commonjs - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-module commonjs -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-module commonjs -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/package-module-fallback - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-module commonjs -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output commonjs:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-module commonjs -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output commonjs:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/module-overrides-package - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-module esmodule -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output commonjs:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-module esmodule -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output commonjs:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/resolution-null - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/resolution-node - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-module-resolution node -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-module-resolution node -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/resolution-node16 - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-module-resolution node16 -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-module-resolution node16 -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/resolution-bundler - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-module-resolution bundler -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-module-resolution bundler -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/export-null - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/export-false - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/export-true - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-export-interfaces -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-export-interfaces -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/extension-null - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/extension - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-generated-extension .gen.tsx -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-generated-extension .gen.tsx -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/explicit-suffix - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-suffix .mjs -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-suffix .mjs -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/shims-empty-object - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/shims-object - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-shim A=One -bs-gentype-shim B=Two -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-shim A=One -bs-gentype-shim B=Two -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/shims-empty-list - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/shims-list - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-shim A=One -bs-gentype-shim B=Two -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-shim A=One -bs-gentype-shim B=Two -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/shims-empty-source - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-shim =Target -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-shim =Target -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/shims-empty-target - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-shim Source= -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-shim Source= -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/debug-empty - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/debug-values - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-debug m -bs-gentype-debug z -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-debug m -bs-gentype-debug z -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/dependency - compiler: -I ../ocaml -runtime-path -I /node_modules/dep/lib/ocaml -bs-gentype -bs-gentype-dep dep -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -I /node_modules/dep/lib/rescript -bs-gentype -bs-gentype-dep dep -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/source - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res gentype/unknown-field - compiler: -I ../ocaml -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js src/A.ast - parser: -absname -bs-ast -o src/A.ast ../../src/A.res + compiler: -I . -runtime-path -bs-gentype -bs-gentype-bsb-project-root -bs-package-name config-shape -bs-project-root -bs-package-output esmodule:src:.js A.ast + parser: -absname -bs-ast -o A.ast ../../src/A.res diff --git a/rewatch/MonorepoSupport.md b/rewatch/MonorepoSupport.md index ee876a6b715..f4c8bc24d03 100644 --- a/rewatch/MonorepoSupport.md +++ b/rewatch/MonorepoSupport.md @@ -124,21 +124,21 @@ Even when building from a leaf package, some settings are inherited from the **r ### Directory Structure -Each package compiles into: +Each package compiles into one flat directory, keyed by the compiler's file +name of each module (`X` or `X-Ns`): ``` / ├── lib/ -│ ├── bs/ # Build working directory (AST files, intermediate outputs) -│ └── ocaml/ # Published artifacts (.cmi, .cmj, .cmt, .cmti) +│ └── rescript/ # ASTs, .cmi, .cmj, .cmt, .cmti, namespace maps, build state ``` ### Compilation Process For package `A` depending on package `B`: -1. **bsc runs with CWD** = `/lib/bs` -2. **Include path** = `-I /lib/ocaml` for each declared dependency -3. **Own artifacts** = `-I ../ocaml` (relative path to own lib/ocaml) +1. **bsc runs with CWD** = `/lib/rescript` +2. **Include path** = `-I /lib/rescript` for each declared dependency +3. **Own artifacts** = `-I .` ### Dependency Filtering @@ -196,18 +196,18 @@ function BUILD(entryFolder): for package in packages: scan sources (type:dev only included if package.is_local_dep) compute module names (apply namespace suffix rules) - ensure lib/bs + lib/ocaml exist + ensure lib/rescript exists enforce global unique module names # Step 4: Build loop - 1. Parse dirty sources: bsc -bs-ast, cwd=/lib/bs + 1. Parse dirty sources: bsc -bs-ast, cwd=/lib/rescript 2. Compute module deps from AST; filter by declared package deps 3. Compile in dependency-order waves: - - bsc cwd=/lib/bs - - include: -I ../ocaml -I /lib/ocaml for each declared dep + - bsc cwd=/lib/rescript + - include: -I . -I /lib/rescript for each declared dep - runtime: -runtime-path <@rescript/runtime resolved> - package specs: from rootConfig - 4. Copy artifacts to /lib/ocaml + 4. Write each changed .cmi to /lib/rescript once its compile succeeded ``` --- diff --git a/rewatch/tests/clean/03-clean-node-modules.sh b/rewatch/tests/clean/03-clean-node-modules.sh index 7fe0810062e..0b2c583fb8c 100755 --- a/rewatch/tests/clean/03-clean-node-modules.sh +++ b/rewatch/tests/clean/03-clean-node-modules.sh @@ -27,13 +27,13 @@ then fi # Count compiled files in the cleaned project -compiler_assets=$(find node_modules/rescript-nodejs/lib/ocaml -type f -name '*.*' | wc -l | tr -d '[:space:]') +compiler_assets=$(find node_modules/rescript-nodejs/lib/rescript -type f -name '*.*' 2>/dev/null | wc -l | tr -d '[:space:]') if [ $compiler_assets -eq 0 ]; then success "compiler assets from node_modules cleaned" git restore --worktree -- . else - error "Expected 0 files in node_modules/rescript-nodejs/lib/ocaml after clean, got $compiler_assets" + error "Expected 0 files in node_modules/rescript-nodejs/lib/rescript after clean, got $compiler_assets" printf "%s\n" "$error_output" exit 1 fi diff --git a/rewatch/tests/gentype/project-root.mjs b/rewatch/tests/gentype/project-root.mjs index c714ae1538d..70dbfb33e0b 100644 --- a/rewatch/tests/gentype/project-root.mjs +++ b/rewatch/tests/gentype/project-root.mjs @@ -91,13 +91,13 @@ function checkEditorCompilation(buildDirectory) { // and omits generated-JavaScript output while retaining the GenType flags. args.splice(args.indexOf("-bs-package-output"), 2); args.pop(); - const incrementalDir = join(buildDirectory, "lib", "bs", "___incremental"); + const incrementalDir = join(buildDirectory, "lib", "rescript", "incremental"); mkdirSync(incrementalDir); const source = join(incrementalDir, "Editor.res"); writeFileSync(source, "@genType\nlet value = 42\n"); const compiled = spawnSync(bsc_exe, [...args, source], { ...options, - cwd: join(buildDirectory, "lib", "bs"), + cwd: join(buildDirectory, "lib", "rescript"), }); assert.ifError(compiled.error); assert.equal(compiled.status, 0, `${compiled.stdout}\n${compiled.stderr}`); diff --git a/rewatch/tests/lock/01-lock-when-watching.sh b/rewatch/tests/lock/01-lock-when-watching.sh index deb80eb4e82..a3810f3828c 100755 --- a/rewatch/tests/lock/01-lock-when-watching.sh +++ b/rewatch/tests/lock/01-lock-when-watching.sh @@ -27,7 +27,7 @@ clear_locks rewatch_bg watch > /dev/null 2>&1 & success "Watcher Started" -if ! wait_for_file "lib/watch.lock" 40; then +if ! wait_for_file "lib/rescript/watch.lock" 40; then error "watch.lock was not created" exit 1 fi @@ -60,7 +60,7 @@ fi success "Build succeeds while watcher is running" -if wait_for_file_gone "lib/build.lock" 20; +if wait_for_file_gone "lib/rescript/build.lock" 20; then success "build.lock is removed after build finishes" else @@ -68,7 +68,7 @@ else exit 1 fi -if [ -f lib/watch.lock ]; +if [ -f lib/rescript/watch.lock ]; then success "watch.lock remains while watcher is running" else @@ -80,14 +80,14 @@ if ! exit_watcher; then exit 1 fi -if ! wait_for_file_gone "lib/watch.lock" 20; then +if ! wait_for_file_gone "lib/rescript/watch.lock" 20; then error "watch.lock was not removed" exit 1 fi rewatch_bg watch > rewatch.log 2>&1 & -if wait_for_file "lib/watch.lock" 40; then +if wait_for_file "lib/rescript/watch.lock" 40; then success "Watcher can start again after watch.lock is removed" else error "Watcher did not restart after watch.lock removal" diff --git a/rewatch/tests/snapshots/dependency-cycle.txt b/rewatch/tests/snapshots/dependency-cycle.txt index 06f73f80deb..b2f6f42c1bb 100644 --- a/rewatch/tests/snapshots/dependency-cycle.txt +++ b/rewatch/tests/snapshots/dependency-cycle.txt @@ -1,4 +1,4 @@ -Cleaned 0/510 +Cleaned 0/512 Parsed 2 source files Compiled 1 modules diff --git a/rewatch/tests/snapshots/dev-dependency-used-by-non-dev-source.txt b/rewatch/tests/snapshots/dev-dependency-used-by-non-dev-source.txt index 578189b4b2a..37d184def2d 100644 --- a/rewatch/tests/snapshots/dev-dependency-used-by-non-dev-source.txt +++ b/rewatch/tests/snapshots/dev-dependency-used-by-non-dev-source.txt @@ -1,4 +1,4 @@ -Cleaned 0/510 +Cleaned 0/512 Parsed 2 source files Compiled 2 modules diff --git a/rewatch/tests/snapshots/remove-file.txt b/rewatch/tests/snapshots/remove-file.txt index 78756a9b83f..09793fc99b4 100644 --- a/rewatch/tests/snapshots/remove-file.txt +++ b/rewatch/tests/snapshots/remove-file.txt @@ -1,4 +1,4 @@ -Cleaned 1/510 +Cleaned 1/512 Parsed 1 source files Compiled 2 modules diff --git a/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt b/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt index bcd4157e4ef..eba51ac865d 100644 --- a/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt +++ b/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt @@ -1,4 +1,4 @@ -Cleaned 1/510 +Cleaned 1/512 Parsed 2 source files Compiled 3 modules diff --git a/rewatch/tests/snapshots/rename-file-internal-dep.txt b/rewatch/tests/snapshots/rename-file-internal-dep.txt index 39989f4bba5..2d70eb9abf1 100644 --- a/rewatch/tests/snapshots/rename-file-internal-dep.txt +++ b/rewatch/tests/snapshots/rename-file-internal-dep.txt @@ -1,4 +1,4 @@ -Cleaned 1/510 +Cleaned 1/512 Parsed 2 source files Compiled 3 modules diff --git a/rewatch/tests/snapshots/rename-file-with-interface.txt b/rewatch/tests/snapshots/rename-file-with-interface.txt index f33ff54867b..e1f7d0f079e 100644 --- a/rewatch/tests/snapshots/rename-file-with-interface.txt +++ b/rewatch/tests/snapshots/rename-file-with-interface.txt @@ -1,5 +1,5 @@  No implementation file found for interface file (skipping): src/ModuleWithInterface.resi -Cleaned 2/510 +Cleaned 2/512 Parsed 2 source files Compiled 2 modules diff --git a/rewatch/tests/snapshots/rename-file.txt b/rewatch/tests/snapshots/rename-file.txt index c63fe8b997e..634965c0f6d 100644 --- a/rewatch/tests/snapshots/rename-file.txt +++ b/rewatch/tests/snapshots/rename-file.txt @@ -1,4 +1,4 @@ -Cleaned 1/510 +Cleaned 1/512 Parsed 2 source files Compiled 2 modules diff --git a/rewatch/tests/snapshots/rename-interface-file.txt b/rewatch/tests/snapshots/rename-interface-file.txt index 1b27f5bbfb6..c70ddc99ea7 100644 --- a/rewatch/tests/snapshots/rename-interface-file.txt +++ b/rewatch/tests/snapshots/rename-interface-file.txt @@ -1,5 +1,5 @@  No implementation file found for interface file (skipping): src/ModuleWithInterface2.resi -Cleaned 1/510 +Cleaned 1/512 Parsed 2 source files Compiled 2 modules diff --git a/rewatch/tests/suffix/01-custom-suffix.sh b/rewatch/tests/suffix/01-custom-suffix.sh index 0485d49c2ab..bf89e14a65f 100755 --- a/rewatch/tests/suffix/01-custom-suffix.sh +++ b/rewatch/tests/suffix/01-custom-suffix.sh @@ -32,7 +32,7 @@ fi # Count files with new extension file_count=$(find ./packages -name *.res.js | wc -l) -if [ "$file_count" -eq 146 ]; +if [ "$file_count" -eq 73 ]; then success "Found files with correct suffix" else diff --git a/rewatch/tests/utils.sh b/rewatch/tests/utils.sh index 05e94ff681c..62a32ca6c07 100644 --- a/rewatch/tests/utils.sh +++ b/rewatch/tests/utils.sh @@ -72,18 +72,18 @@ wait_for_pid_gone() { exit_watcher() { local watcher_pid="" - if [ -f lib/watch.lock ]; then - watcher_pid=$(cat lib/watch.lock) + if [ -f lib/rescript/watch.lock ]; then + watcher_pid=$(cat lib/rescript/watch.lock) fi # Windows refuses to delete a file while another process has it open # without delete sharing, so a watcher reading the lock can make one # attempt fail. local attempts=0 - until rm -f lib/watch.lock 2> /dev/null; do + until rm -f lib/rescript/watch.lock 2> /dev/null; do attempts=$((attempts + 1)) if [ "$attempts" -ge 50 ]; then - rm -f lib/watch.lock + rm -f lib/rescript/watch.lock break fi sleep 0.1 @@ -93,7 +93,7 @@ exit_watcher() { if ! wait_for_pid_gone "$watcher_pid" 20; then error "Watcher process $watcher_pid did not exit after watch.lock was removed" kill_process "$watcher_pid" - rm -f lib/watch.lock + rm -f lib/rescript/watch.lock return 1 fi fi @@ -113,7 +113,7 @@ kill_process() { } clear_locks() { - rm -f lib/watch.lock lib/build.lock + rm -f lib/rescript/watch.lock lib/rescript/build.lock } wait_for_file() { diff --git a/rewatch/tests/watch/02-watch-warnings-persist-atomic-save.sh b/rewatch/tests/watch/02-watch-warnings-persist-atomic-save.sh index 067ae6b33c9..a41f7b10b84 100755 --- a/rewatch/tests/watch/02-watch-warnings-persist-atomic-save.sh +++ b/rewatch/tests/watch/02-watch-warnings-persist-atomic-save.sh @@ -28,7 +28,7 @@ wait_for_changed_completed_log() { return 1 } -COMPILER_LOG="./packages/watch-warnings/lib/bs/.compiler.log" +COMPILER_LOG="./packages/watch-warnings/lib/rescript/.compiler.log" B_FILE="./packages/watch-warnings/src/B.res" WATCH_STDOUT="rewatch-stdout.log" WATCH_STDERR="rewatch-stderr.log" diff --git a/rewatch/tests/watch/04-watch-config-change.sh b/rewatch/tests/watch/04-watch-config-change.sh index c32ccf4ba5c..15e79e6a8f4 100755 --- a/rewatch/tests/watch/04-watch-config-change.sh +++ b/rewatch/tests/watch/04-watch-config-change.sh @@ -93,7 +93,7 @@ if ! wait_for_file_gone "./src/Test.mjs" 20; then fi # Verify the watcher is still running (didn't crash on config change) -if [ -f lib/watch.lock ]; then +if [ -f lib/rescript/watch.lock ]; then success "Watcher still running after config change" else error "Watcher crashed after config change" diff --git a/rewatch/tests/watch/07-changed-interface-after-failed-implementation.sh b/rewatch/tests/watch/07-changed-interface-after-failed-implementation.sh index 62c3edf00df..7de72226c2b 100755 --- a/rewatch/tests/watch/07-changed-interface-after-failed-implementation.sh +++ b/rewatch/tests/watch/07-changed-interface-after-failed-implementation.sh @@ -42,7 +42,7 @@ EOF cd "$fixture" || exit 1 REWATCH_COMPILER_DOMAINS=1 "$REWATCH_EXECUTABLE" watch > rewatch.log 2>&1 & watch_pid=$! -compiler_log=lib/bs/.compiler.log +compiler_log=lib/rescript/.compiler.log wait_for_changed_compiler_log() { local baseline="$1"; local timeout @@ -83,8 +83,8 @@ cp "$compiler_log" failed.compiler.log # Keep timestamp-based freshness from masking a lost dirty bit. Both watcher # implementations must remember that Consumer was blocked by Provider's failed # implementation when the next rebuild reconstructs the build state. -test -f lib/ocaml/Consumer.cmt -node -e 'const fs = require("fs"); const future = new Date(Date.now() + 60000); fs.utimesSync("lib/ocaml/Consumer.cmt", future, future)' +test -f lib/rescript/Consumer.cmt +node -e 'const fs = require("fs"); const future = new Date(Date.now() + 60000); fs.utimesSync("lib/rescript/Consumer.cmt", future, future)' # An atomic replacement makes the watcher reinitialize its build state. The # blocked dependent must remain dirty through that full rebuild as well. diff --git a/rewatch/tests/watch/09-watch-recovers-from-invalid-config.sh b/rewatch/tests/watch/09-watch-recovers-from-invalid-config.sh index 9cbf472b000..45363bf32bf 100755 --- a/rewatch/tests/watch/09-watch-recovers-from-invalid-config.sh +++ b/rewatch/tests/watch/09-watch-recovers-from-invalid-config.sh @@ -69,7 +69,7 @@ for invalid_config in '{"name":' '{"name":"watch-recovery","jsx":{"version":3}}' if wait_for_pattern outputs.log "$previous_output" 5; then fail_test "Watcher compiled the source using stale configuration" fi - process_is_running "$(cat lib/watch.lock)" || fail_test "Watcher exited after the config error" + process_is_running "$(cat lib/rescript/watch.lock)" || fail_test "Watcher exited after the config error" node - "$iteration" <<'JS' const fs = require("fs"); @@ -85,7 +85,7 @@ JS if grep -Fq "$previous_output" outputs.log; then fail_test "Watcher emitted stale output before recovering" fi - wait_for_file_gone lib/build.lock 20 || fail_test "Recovery left the build lock behind" + wait_for_file_gone lib/rescript/build.lock 20 || fail_test "Recovery left the build lock behind" previous_output="Test.recovered$iteration.mjs" done diff --git a/tests/ounit_tests/ounit_build_file_store_tests.ml b/tests/ounit_tests/ounit_build_file_store_tests.ml index 68ad9573aa6..67245cd50ab 100644 --- a/tests/ounit_tests/ounit_build_file_store_tests.ml +++ b/tests/ounit_tests/ounit_build_file_store_tests.ml @@ -108,6 +108,131 @@ let kept_and_evicted_tests _ = assert_bool "an evicted file exists" (Build_file_store.exists kept)); assert_equal ~printer (Some "interface") (Build_file_store.read kept)) +(* A held interface stays off the disk until it is published, and publishing + writes it only when it changed, so an unchanged interface keeps its + modification time. A forgotten one never reaches the disk. *) +let held_writes_tests _ = + with_temp_dir (fun root -> + let interface = Filename.concat root "A.cmi" in + let unchanged = Filename.concat root "B.cmi" in + let failed = Filename.concat root "C.cmi" in + let implementation = Filename.concat root "A.cmj" in + List.iter + (fun path -> write_on_disk path "old") + [interface; unchanged; failed]; + let on_disk path = + let channel = open_in_bin path in + Fun.protect + ~finally:(fun () -> close_in_noerr channel) + (fun () -> really_input_string channel (in_channel_length channel)) + in + let written = ref [] in + let write path contents = + written := path :: !written; + write_on_disk path contents + in + Build_file_store.set_held_writes (fun path -> + Filename.check_suffix path ".cmi"); + Fun.protect + ~finally:(fun () -> Build_file_store.set_held_writes (fun _ -> false)) + (fun () -> + Build_file_store.with_build (fun () -> + Build_file_store.write interface "new"; + Build_file_store.write unchanged "old"; + Build_file_store.write failed "new"; + Build_file_store.write implementation "code"; + assert_equal ~printer (Some "new") + (Build_file_store.read interface); + assert_equal ~printer (Some "old") (Some (on_disk interface)); + assert_equal ~printer (Some "code") + (Some (on_disk implementation)); + assert_bool "a changed interface is published" + (Build_file_store.publish_held ~if_changed:true ~write interface); + assert_bool "an unchanged interface is not rewritten" + (not + (Build_file_store.publish_held ~if_changed:true ~write + unchanged)); + assert_equal ~printer:(String.concat ",") [interface] !written; + assert_raises Not_found (fun () -> + Build_file_store.publish_held ~if_changed:true ~write + interface); + Build_file_store.forget failed; + assert_equal ~printer (Some "old") (Build_file_store.read failed)); + assert_equal ~printer (Some "new") (Some (on_disk interface)); + assert_equal ~printer (Some "old") (Some (on_disk failed)))) + +(* Publishing compares a held interface with the one the build read before, + without reading the disk again. *) +let held_write_compares_read_contents_tests _ = + with_temp_dir (fun root -> + let path = Filename.concat root "A.cmi" in + write_on_disk path "interface"; + let reads = ref 0 in + Build_file_store.set_held_writes (fun _ -> true); + Fun.protect + ~finally:(fun () -> + Build_file_store.set_held_writes (fun _ -> false); + Build_file_store.set_disk_reader Bs_cmi_load.read_file) + (fun () -> + Build_file_store.with_build (fun () -> + ignore (Build_file_store.read path); + Build_file_store.set_disk_reader (fun path -> + incr reads; + Bs_cmi_load.read_file path); + Build_file_store.write path "interface"; + assert_bool "an identical interface is not published" + (not + (Build_file_store.publish_held ~if_changed:true + ~write:(fun _ _ -> assert_failure "written") + path)); + assert_equal ~printer:string_of_int 0 !reads))) + +(* Large files that one request reads, such as typed trees, are not kept, but + held contents are seen. *) +let read_without_keeping_tests _ = + with_temp_dir (fun root -> + let read = Filename.concat root "B.cmt" in + let held = Filename.concat root "A.cmt" in + write_on_disk read "typed tree"; + Build_file_store.set_held_writes (fun path -> + Filename.check_suffix path ".cmt"); + Fun.protect + ~finally:(fun () -> Build_file_store.set_held_writes (fun _ -> false)) + (fun () -> + Build_file_store.with_build (fun () -> + assert_equal ~printer (Some "typed tree") + (Build_file_store.read ~keep:false read); + assert_equal ~printer None (Build_file_store.cached read); + assert_bool "a file read once exists" + (Build_file_store.exists read); + Build_file_store.write held "held typed tree"; + assert_equal ~printer (Some "held typed tree") + (Build_file_store.read ~keep:false held)))) + +(* An existing interface cut short, as by a build killed while it wrote it in + place, is replaced instead of failing the compile that checks it. *) +let truncated_existing_interface_tests _ = + with_temp_dir (fun root -> + let path = Filename.concat root "Abc.cmi" in + write_on_disk path (Config.cmi_magic_number ^ "cut"); + Compiler_request_state.with_fresh ~cwd:root (fun () -> + ignore + (Cmi_format.create_cmi ~check_exists:() path + { + Cmi_format.cmi_name = "Abc"; + cmi_sign = []; + cmi_crcs = []; + cmi_flags = []; + })); + let contents = + let channel = open_in_bin path in + Fun.protect + ~finally:(fun () -> close_in_noerr channel) + (fun () -> really_input_string channel (in_channel_length channel)) + in + assert_bool "a truncated interface is replaced" + (String.length contents > String.length Config.cmi_magic_number + 3)) + (* A file that the compiler removes, such as a stale source map, is missing for the rest of the build. *) let removed_file_tests _ = @@ -312,6 +437,11 @@ let suites = "build_reads_once" >:: build_reads_once_tests; "spellings_share_an_entry" >:: spellings_share_an_entry_tests; "kept_and_evicted" >:: kept_and_evicted_tests; + "held_writes" >:: held_writes_tests; + "held_write_compares_read_contents" + >:: held_write_compares_read_contents_tests; + "read_without_keeping" >:: read_without_keeping_tests; + "truncated_existing_interface" >:: truncated_existing_interface_tests; "removed_file" >:: removed_file_tests; "unreadable_file" >:: unreadable_file_tests; "concurrent_domains" >:: concurrent_domains_tests; diff --git a/tests/ounit_tests/ounit_compiler_request_tests.ml b/tests/ounit_tests/ounit_compiler_request_tests.ml index 303b0c4e6be..24b121ef3c5 100644 --- a/tests/ounit_tests/ounit_compiler_request_tests.ml +++ b/tests/ounit_tests/ounit_compiler_request_tests.ml @@ -1666,7 +1666,7 @@ let concurrent_request_isolation_tests _context = let concurrent_async_context_tests _context = with_temp_dir "rewatch-driver-async-domains-" (fun root -> let runtime = Runtime_package.get_path () in - let runtime_ocaml = Filename.concat runtime "lib/ocaml" in + let runtime_artifacts = Filename.concat runtime "lib/rescript" in let async_source = "external get: unit => promise = \"get\"\n" ^ (List.init 80 (fun index -> @@ -1700,7 +1700,7 @@ let concurrent_async_context_tests _context = List.iter (fun input -> let _, result = - run directory ~extra:["-I"; runtime_ocaml] input + run directory ~extra:["-I"; runtime_artifacts] input in if result.exit_code <> 0 then assert_failure (Printf.sprintf "%s: %s" input result.stderr)) diff --git a/tests/rewatch_ounit_tests/build_artifacts_tests.ml b/tests/rewatch_ounit_tests/build_artifacts_tests.ml index 48ab9990066..f2e4f3bdf29 100644 --- a/tests/rewatch_ounit_tests/build_artifacts_tests.ml +++ b/tests/rewatch_ounit_tests/build_artifacts_tests.ml @@ -6,12 +6,13 @@ let write_file = Test_support.write_file let with_temp_dir = Test_support.with_temp_dir "rewatch-build-artifacts-" -let cleanup_stale ~ocaml_files ~ast_sources ~source_files - ?(present_source_files = source_files) ?(on_removed_module = ignore) - ?(on_deferred_artifact = ignore) ~root ~is_local config modules = - Build_artifacts.cleanup_stale ~ocaml_files ~ast_sources ~source_files - ~present_source_files ~on_removed_module ~on_deferred_artifact ~root - ~is_local config modules +let cleanup_stale ~artifact_files ~ast_sources ?(present_source_files = []) + ?(on_removed_module = ignore) ~root config modules = + Build_artifacts.cleanup_stale ~artifact_files ~ast_sources + ~present_source_files ~on_removed_module ~root config modules + +let module_ ?interface name implementation : Source.module_ = + {name; implementation; interface; is_dev = false} let tests = "build_artifacts_tests" >:: fun _context -> @@ -20,218 +21,178 @@ let tests = let source = Test_support.path root "src/Old.res" in let public_output = Test_support.path root "src/Old.bs.js" in let public_map = public_output ^ ".map" in - let build_dir = Test_support.path root "lib/bs" in - let working_dir = Filename.concat build_dir "src" in - let working_ast = Filename.concat working_dir "Old.ast" in - let working_cmi = Filename.concat working_dir "Old-Ns.cmi" in - let working_output = Filename.concat working_dir "Old.bs.js" in - let working_map = working_output ^ ".map" in - let ocaml_dir = Test_support.path root "lib/ocaml" in - let published_ast = Filename.concat ocaml_dir "Old.ast" in - let published_cmi = Filename.concat ocaml_dir "Old-Ns.cmi" in + let artifact_dir = Test_support.path root "lib/rescript" in + let ast = Filename.concat artifact_dir "Old.ast" in + let cmi = Filename.concat artifact_dir "Old-Ns.cmi" in + let cmj = Filename.concat artifact_dir "Old-Ns.cmj" in write_file config_path {|{"name":"cleanup","namespace":"Ns","sources":{"dir":"src"},"package-specs":{"module":"esmodule","in-source":true,"suffix":".bs.js"}}|}; List.iter (fun path -> write_file path "generated") - [ - public_output; - public_map; - working_ast; - working_cmi; - working_output; - working_map; - published_ast; - published_cmi; - ]; + [public_output; public_map; ast; cmi; cmj]; let config = Config.load_root root in - let deferred_artifacts = ref [] in + let removed = ref [] in let result = cleanup_stale - ~on_deferred_artifact:(fun path -> - deferred_artifacts := path :: !deferred_artifacts) - ~ocaml_files:[published_ast; published_cmi] - ~ast_sources: - [{Compile_assets.ast_path = published_ast; source_path = source}] - ~source_files:[public_output; public_map] - ~root ~is_local:true config [] + ~on_removed_module:(fun name -> removed := name :: !removed) + ~artifact_files:[ast; cmi; cmj] + ~ast_sources:[{Compile_assets.ast_path = ast; source_path = source}] + ~present_source_files:[public_output; public_map] + ~root config [] in List.iter (fun path -> check (not (Sys.file_exists path)) - ("direct cleanup should remove " ^ path)) - [ - public_output; - public_map; - working_ast; - working_output; - working_map; - published_ast; - published_cmi; - ]; + ("a removed source's artifacts and outputs are removed: " ^ path)) + [public_output; public_map; ast; cmi; cmj]; check - (Sys.file_exists working_cmi) - "a directly mapped working CMI remains available through compilation"; - check - (!deferred_artifacts = [working_cmi]) - "direct cleanup transfers ownership of the deferred working CMI"; - check - (result.removed_modules = ["Old"]) + (result.removed_modules = ["Old"] && !removed = ["Old"]) "a removed AST records its module for invalidation"); with_temp_dir (fun root -> let config_path = Filename.concat root "rescript.json" in - let ocaml_dir = Test_support.path root "lib/ocaml" in - let published_cmt = Filename.concat ocaml_dir "Legacy.cmt" in - let working_cmt = Test_support.path root "lib/bs/nested/Legacy.cmt" in + let artifact_dir = Test_support.path root "lib/rescript" in + let unexpected = Filename.concat artifact_dir "Legacy.cmt" in + let leftover = + Filename.concat artifact_dir (File_util.atomic_write_prefix ^ "1a2b.tmp") + in + let kept = + List.map + (Filename.concat artifact_dir) + [ + ".compiler.log"; + "compiler-info.json"; + ".sourcedirs.json"; + "build.lock"; + "watch.lock"; + ".build-lock-1a2b.tmp"; + ] + in write_file config_path {|{"name":"cleanup"}|}; - write_file published_cmt "published"; - write_file working_cmt "working"; - let config = Config.load_root root in - ignore - (cleanup_stale ~ocaml_files:[published_cmt] ~ast_sources:[] - ~source_files:[] ~root ~is_local:true config []); - check - (not (Sys.file_exists working_cmt)) - "unmapped legacy artifacts fall back to the recursive working inventory"); - with_temp_dir (fun root -> - let config_path = Filename.concat root "rescript.json" in - let old_output = Test_support.path root "src/A.js" in - let old_map = old_output ^ ".map" in - let working_output = Test_support.path root "lib/bs/src/A.js" in - let working_map = working_output ^ ".map" in - write_file config_path - {|{"name":"cleanup-map","sources":{"dir":"src","subdirs":true},"package-specs":{"module":"esmodule","in-source":true}}|}; List.iter - (fun path -> write_file path "generated") - [old_output; old_map; working_output; working_map]; + (fun path -> write_file path "contents") + (unexpected :: leftover :: kept); let config = Config.load_root root in - let moved_module : Source.module_ = - { - name = "A"; - implementation = "src/nested/A.res"; - interface = None; - is_dev = false; - } - in + let inventory = Compile_assets.create [artifact_dir] in ignore - (cleanup_stale ~ocaml_files:[] ~ast_sources:[] - ~source_files:[old_output; old_map] ~root ~is_local:true config - [moved_module]); + (cleanup_stale + ~artifact_files:(Compile_assets.files inventory artifact_dir) + ~ast_sources:[] ~root config []); + check + (not (Sys.file_exists leftover)) + "a file a killed build was writing is removed"; + check + (not (Sys.file_exists unexpected)) + "an artifact of no current module is removed"; List.iter (fun path -> - check - (not (Sys.file_exists path)) - ("moving a source removes its stale output family: " ^ path)) - [old_output; old_map; working_output; working_map]); + check (Sys.file_exists path) + ("build state is not an artifact: " ^ path)) + kept); with_temp_dir (fun root -> let config_path = Filename.concat root "rescript.json" in let old_source = Test_support.path root "src/A.res" in let new_source = Test_support.path root "src/nested/A.res" in - let ocaml_dir = Test_support.path root "lib/ocaml" in - let published_ast = Filename.concat ocaml_dir "A.ast" in - let working_ast = Test_support.path root "lib/bs/src/A.ast" in + let old_output = Test_support.path root "src/A.js" in + let old_map = old_output ^ ".map" in + let new_output = Test_support.path root "src/nested/A.js" in + let artifact_dir = Test_support.path root "lib/rescript" in + let ast = Filename.concat artifact_dir "A.ast" in write_file config_path - {|{"name":"moved-source","sources":{"dir":"src","subdirs":true}}|}; + {|{"name":"moved-source","sources":{"dir":"src","subdirs":true},"package-specs":{"module":"esmodule","in-source":true}}|}; write_file new_source "let value = 1"; - Test_support.write_ast_header published_ast ~dependencies:["Dependency"] + List.iter + (fun path -> write_file path "generated") + [old_output; old_map; new_output]; + Test_support.write_ast_header ast ~dependencies:["Dependency"] ~source:old_source; - write_file working_ast "old working AST"; let config = Config.load_root root in - let module_ : Source.module_ = - { - name = "A"; - implementation = "src/nested/A.res"; - interface = None; - is_dev = false; - } - in - let compile_assets = Compile_assets.create [ocaml_dir] in + let moved = module_ "A" "src/nested/A.res" in + let compile_assets = Compile_assets.create [artifact_dir] in let result = - cleanup_stale ~ocaml_files:[published_ast] + cleanup_stale ~artifact_files:[ast] ~ast_sources: - [ - {Compile_assets.ast_path = published_ast; source_path = old_source}; - ] - ~source_files:[new_source] ~root ~is_local:true config [module_] + [{Compile_assets.ast_path = ast; source_path = old_source}] + ~present_source_files:[old_output; old_map; new_output] + ~root config [moved] in + List.iter + (fun path -> + check + (not (Sys.file_exists path)) + ("moving a source removes its old output: " ^ path)) + [old_output; old_map]; check - (not (Sys.file_exists published_ast || Sys.file_exists working_ast)) + (Sys.file_exists new_output) + "moving a source keeps the output at its new location"; + check + (not (Sys.file_exists ast)) "moving a source invalidates the AST associated with its old path"; check (List.mem "A" result.removed_modules) "moving a source marks its module for recompilation"; check (Build_freshness.source_is_not_older_than_ast compile_assets ~root - ~source_mtimes:(Hashtbl.create 0) module_.implementation) - "a moved source cannot reuse the published AST for its old path"); + ~source_mtimes:(Hashtbl.create 0) moved.implementation) + "a moved source cannot reuse the AST for its old path"); + with_temp_dir (fun root -> + let config_path = Filename.concat root "rescript.json" in + let authored = Test_support.path root "src/Authored.js" in + write_file config_path + {|{"name":"authored","sources":"src","package-specs":{"module":"commonjs","in-source":true}}|}; + write_file authored "module.exports = {}"; + let config = Config.load_root root in + ignore + (cleanup_stale ~artifact_files:[] ~ast_sources:[] + ~present_source_files:[authored] ~root config []); + check (Sys.file_exists authored) + "JavaScript without an AST proving that the build generated it is kept"); with_temp_dir (fun root -> let config_path = Filename.concat root "rescript.json" in let old_source = Test_support.path root "old/Foo.res" in let old_output = Test_support.path root "old/Foo.js" in let old_map = old_output ^ ".map" in - let working_output = Test_support.path root "lib/bs/old/Foo.js" in - let working_map = working_output ^ ".map" in - let ocaml_dir = Test_support.path root "lib/ocaml" in - let published_ast = Filename.concat ocaml_dir "Foo.ast" in + let ast = Test_support.path root "lib/rescript/Foo.ast" in write_file config_path {|{"name":"cleanup-removed-source-dir","sources":"src","package-specs":{"module":"esmodule","in-source":true}}|}; List.iter (fun path -> write_file path "generated") - [ - old_source; - old_output; - old_map; - working_output; - working_map; - published_ast; - ]; + [old_source; old_output; old_map; ast]; let config = Config.load_root root in ignore - (cleanup_stale ~ocaml_files:[published_ast] + (cleanup_stale ~artifact_files:[ast] ~ast_sources: - [ - { - Compile_assets.ast_path = published_ast; - source_path = old_source; - }; - ] - ~source_files:[] ~root ~is_local:true config []); + [{Compile_assets.ast_path = ast; source_path = old_source}] + ~root config []); List.iter (fun path -> check (not (Sys.file_exists path)) - ("removing a source directory removes its stale output family: " - ^ path)) - [old_output; old_map; working_output; working_map]); + ("removing a source directory removes its stale outputs: " ^ path)) + [old_output; old_map]); with_temp_dir (fun root -> let config_path = Filename.concat root "rescript.json" in let source = Test_support.path root "src/Custom.res" in let public_output = Test_support.path root "src/Custom.generated.js" in let public_map = public_output ^ ".map" in - let working_output = - Test_support.path root "lib/bs/src/Custom.generated.js" - in - let working_map = working_output ^ ".map" in - let ocaml_dir = Test_support.path root "lib/ocaml" in - let published_ast = Filename.concat ocaml_dir "Custom.ast" in + let ast = Test_support.path root "lib/rescript/Custom.ast" in write_file config_path {|{"name":"custom-cleanup","sources":"src","package-specs":{"module":"esmodule","in-source":true,"suffix":".generated.js"}}|}; List.iter (fun path -> write_file path "generated") - [public_output; public_map; working_output; working_map; published_ast]; + [public_output; public_map; ast]; let config = Config.load_root root in ignore - (cleanup_stale ~ocaml_files:[published_ast] - ~ast_sources: - [{Compile_assets.ast_path = published_ast; source_path = source}] - ~source_files:[public_output; public_map] - ~root ~is_local:true config []); + (cleanup_stale ~artifact_files:[ast] + ~ast_sources:[{Compile_assets.ast_path = ast; source_path = source}] + ~present_source_files:[public_output; public_map] + ~root config []); List.iter (fun path -> check (not (Sys.file_exists path)) ("custom suffix cleanup removes " ^ path)) - [public_output; public_map; working_output; working_map]); + [public_output; public_map]); with_temp_dir (fun root -> let config_path = Filename.concat root "rescript.json" in let output = Test_support.path root "src/Present.output" in @@ -239,76 +200,78 @@ let tests = {|{"name":"custom-freshness","sources":"src","package-specs":{"module":"esmodule","in-source":true,"suffix":".output"}}|}; write_file output "generated"; let config = Config.load_root root in - let module_ : Source.module_ = - { - name = "Present"; - implementation = "src/Present.res"; - interface = None; - is_dev = false; - } - in let result = - cleanup_stale ~ocaml_files:[] ~ast_sources:[] ~source_files:[output] - ~present_source_files:[output] ~root ~is_local:true config [module_] + cleanup_stale ~artifact_files:[] ~ast_sources:[] + ~present_source_files:[output] ~root config + [module_ "Present" "src/Present.res"] in check (Hashtbl.mem result.present_public_outputs output) "custom suffix outputs participate in unchanged-build freshness"); with_temp_dir (fun root -> let config_path = Filename.concat root "rescript.json" in - let ocaml_dir = Test_support.path root "lib/ocaml" in - let working_dir = Test_support.path root "lib/bs/src" in - let published_cmti = Filename.concat ocaml_dir "A.cmti" in - let working_cmti = Filename.concat working_dir "A.cmti" in + let cmti = Test_support.path root "lib/rescript/A.cmti" in write_file config_path {|{"name":"removed-interface","sources":"src","package-specs":{"module":"esmodule","in-source":true}}|}; - write_file published_cmti "published interface"; - write_file working_cmti "working interface"; + write_file cmti "interface"; let config = Config.load_root root in - let module_ : Source.module_ = - { - name = "A"; - implementation = "src/A.res"; - interface = None; - is_dev = false; - } - in ignore - (cleanup_stale ~ocaml_files:[published_cmti] ~ast_sources:[] - ~source_files:[] ~root ~is_local:true config [module_]); - List.iter - (fun path -> - check - (not (Sys.file_exists path)) - ("removing an interface removes " ^ path)) - [published_cmti; working_cmti]); + (cleanup_stale ~artifact_files:[cmti] ~ast_sources:[] ~root config + [module_ "A" "src/A.res"]); + check + (not (Sys.file_exists cmti)) + "removing an interface removes its typed tree"); with_temp_dir (fun root -> let config_path = Filename.concat root "rescript.json" in let old_source = Test_support.path root "src/generated/A.res" in let generated_output = Test_support.path root "src/generated/A.js" in let authored_output = Test_support.path root "src/handwritten/A.js" in - let ocaml_dir = Test_support.path root "lib/ocaml" in - let published_ast = Filename.concat ocaml_dir "A.ast" in + let ast = Test_support.path root "lib/rescript/A.ast" in write_file config_path {|{"name":"owned-output-path","sources":{"dir":"src","subdirs":true},"package-specs":{"module":"esmodule","in-source":true}}|}; List.iter (fun path -> write_file path "contents") - [generated_output; authored_output; published_ast]; + [generated_output; authored_output; ast]; let config = Config.load_root root in ignore - (cleanup_stale ~ocaml_files:[published_ast] + (cleanup_stale ~artifact_files:[ast] ~ast_sources: - [ - { - Compile_assets.ast_path = published_ast; - source_path = old_source; - }; - ] - ~source_files:[generated_output; authored_output] - ~root ~is_local:true config []); + [{Compile_assets.ast_path = ast; source_path = old_source}] + ~present_source_files:[generated_output; authored_output] + ~root config []); check (not (Sys.file_exists generated_output)) "cleanup removes the output at the historical source location"; check (Sys.file_exists authored_output) - "cleanup preserves unrelated JavaScript with the same basename") + "cleanup preserves unrelated JavaScript with the same basename"); + with_temp_dir (fun root -> + let artifact_dir = Test_support.path root "lib/rescript" in + let artifacts = + List.map + (Filename.concat artifact_dir) + ["A.ast"; "A.cmi"; "incremental/A.cmt"] + in + let locks = + List.map + (Filename.concat artifact_dir) + ["build.lock"; "watch.lock"; ".build-lock-123"] + in + let legacy = + [ + Test_support.path root "lib/bs/src/A.ast"; + Test_support.path root "lib/ocaml/A.cmi"; + ] + in + List.iter + (fun path -> write_file path "contents") + (artifacts @ locks @ legacy); + Build_artifacts.clean root; + List.iter + (fun path -> + check (not (Sys.file_exists path)) ("clean removes " ^ path)) + (artifacts @ legacy); + List.iter + (fun path -> + check (Sys.file_exists path) ("clean keeps the lock " ^ path)) + locks) diff --git a/tests/rewatch_ounit_tests/build_attempt_tests.ml b/tests/rewatch_ounit_tests/build_attempt_tests.ml index 1d739752026..3dad1584899 100644 --- a/tests/rewatch_ounit_tests/build_attempt_tests.ml +++ b/tests/rewatch_ounit_tests/build_attempt_tests.ml @@ -71,14 +71,14 @@ let pending_work_is_drained_once _context = let log_finalization_runs_once _context = Test_support.with_temp_dir "rewatch-attempt-log" (fun root -> let attempt = create_full () in - File_util.ensure_dir (Build_artifacts.lib_path root "ocaml"); + File_util.ensure_dir (Build_artifacts.artifact_dir root); Compiler_log.initialize root; Build_attempt.mark_log_initialized attempt root; Build_attempt.finalize_logs attempt; Build_attempt.finalize_logs attempt; let contents = File_util.read_file - (Filename.concat (Build_artifacts.lib_path root "bs") ".compiler.log") + (Filename.concat (Build_artifacts.artifact_dir root) ".compiler.log") in let done_lines = contents |> String.split_on_char '\n' diff --git a/tests/rewatch_ounit_tests/build_file_tests.ml b/tests/rewatch_ounit_tests/build_file_tests.ml index e32ca267e6e..0c595c4913a 100644 --- a/tests/rewatch_ounit_tests/build_file_tests.ml +++ b/tests/rewatch_ounit_tests/build_file_tests.ml @@ -76,20 +76,18 @@ let ast_header_boundary_tests _context = not the build store still holds it. *) let parsed_dependencies_tests _context = with_temp_dir (fun root -> - let build_dir = Filename.concat root "lib/bs" in - let ocaml_dir = Filename.concat root "lib/ocaml" in + let artifact_dir = Filename.concat root "lib/rescript" in let path = "src/A.res" in let source = Filename.concat root path in + let ast = Build_artifacts.ast_path ~artifact_dir path in Test_support.write_file (Filename.concat root "rescript.json") {|{"name":"graph","sources":{"dir":"src"}}|}; Test_support.write_file source "let a = New.a\n"; - Test_support.write_file - (Build_artifacts.published_ast_path ~ocaml_dir path) - (ast_contents ~dependencies:["Old"] ~source); - Test_support.write_file - (Filename.concat build_dir (Source.ast_path path)) - (ast_contents ~dependencies:["New"] ~source); + Test_support.write_file ast (ast_contents ~dependencies:["Old"] ~source); + let compile_assets = Compile_assets.create [artifact_dir] in + (* This build's parse replaces the AST that the build read before. *) + Test_support.write_file ast (ast_contents ~dependencies:["New"] ~source); let config = Config.load_root root in let package : Package_plan.t = { @@ -98,8 +96,7 @@ let parsed_dependencies_tests _context = is_local = true; config; compile_config = config; - build_dir; - ocaml_dir; + artifact_dir; dependencies = []; gentype_dependency_args = []; modules = @@ -119,8 +116,7 @@ let parsed_dependencies_tests _context = let dependencies parsed_paths = let graph = Module_graph.initialize ~root_config:config ~package_plans:[package] - ~compile_assets:(Compile_assets.create [ocaml_dir]) - ~parsed_paths ~failed_parse_paths:(Hashtbl.create 1) + ~compile_assets ~parsed_paths ~failed_parse_paths:(Hashtbl.create 1) in List.concat_map (fun (node : Module_graph.module_node) -> node.raw_dependencies) @@ -135,34 +131,6 @@ let parsed_dependencies_tests _context = (dependencies parsed_paths = ["New"]) "a module parsed in this build has its new AST's dependencies") -let copy_tests _context = - with_temp_dir (fun root -> - let source = Filename.concat root "A.cmi" in - let destination = Filename.concat root "published.cmi" in - let missing = Filename.concat root "Missing.map" in - Build_file_store.with_build (fun () -> - Build_file_store.write source "interface"; - check - (File_util.copy_build_file_if_different source destination) - "a new destination is copied"; - check - (not (File_util.copy_build_file_if_different source destination)) - "an equal destination is kept"; - Build_file_store.write source "changed"; - check - (File_util.copy_build_file_if_different source destination) - "a changed source is copied"; - File_util.copy_optional_build_file source missing; - File_util.copy_optional_build_file - (Filename.concat root "Absent.map") - missing; - check - (not (Sys.file_exists missing)) - "a missing optional source removes the destination"); - check - (File_util.read_file destination = "changed") - "copies are written to disk") - let parallel_map_tests _context = let items = List.init 1000 Fun.id in check @@ -184,6 +152,5 @@ let tests = "ast_header" >:: ast_header_tests; "ast_header_boundary" >:: ast_header_boundary_tests; "parsed_dependencies" >:: parsed_dependencies_tests; - "copy" >:: copy_tests; "parallel_map" >:: parallel_map_tests; ] diff --git a/tests/rewatch_ounit_tests/clean_tests.ml b/tests/rewatch_ounit_tests/clean_tests.ml index 28eed6f84c1..0266f3a274a 100644 --- a/tests/rewatch_ounit_tests/clean_tests.ml +++ b/tests/rewatch_ounit_tests/clean_tests.ml @@ -62,6 +62,7 @@ let tests = write_file duplicate_output_b "generated duplicate two\n"; write_file duplicate_in_source_a "generated duplicate one\n"; write_file duplicate_in_source_b "generated duplicate two\n"; + write_file (Filename.concat root "lib/rescript/A.cmj") "temporary\n"; write_file (Filename.concat root "lib/bs/compiler-state") "temporary\n"; write_file (Filename.concat root "lib/ocaml/A.cmj") "temporary\n"; Clean.run ~poll:(fun () -> ()) ~verbosity:(-1) ~folder:root ~prod:false; @@ -94,9 +95,12 @@ let tests = check (not (Sys.file_exists duplicate_in_source_b)) "invalid-graph clean removes the second in-source output"; + check + (Sys.readdir (Filename.concat root "lib/rescript") = [||]) + "clean empties the artifact directory, releasing its lock"; check (not (Sys.file_exists (Filename.concat root "lib/bs"))) - "clean removes compiler working artifacts"; + "clean removes the working artifacts of earlier versions"; check (not (Sys.file_exists (Filename.concat root "lib/ocaml"))) - "clean removes published compiler artifacts") + "clean removes the published artifacts of earlier versions") diff --git a/tests/rewatch_ounit_tests/compiler_args_tests.ml b/tests/rewatch_ounit_tests/compiler_args_tests.ml index a6e06fc8904..d1bf39991bf 100644 --- a/tests/rewatch_ounit_tests/compiler_args_tests.ml +++ b/tests/rewatch_ounit_tests/compiler_args_tests.ml @@ -64,16 +64,17 @@ let tests = "dev-dependencies": ["development"] }|}; let regular = - File_util.path_of_parts root ["node_modules"; "regular"; "lib"; "ocaml"] + File_util.path_of_parts root + ["node_modules"; "regular"; "lib"; "rescript"] in let development = File_util.path_of_parts root - ["node_modules"; "development"; "lib"; "ocaml"] + ["node_modules"; "development"; "lib"; "rescript"] in let ordinary_includes = compiler_args source |> adjacent_positions "-I" in check (Option.is_some (position regular ordinary_includes)) - "regular dependency includes do not require a prebuilt lib/ocaml"; + "regular dependency includes do not require a prebuilt lib/rescript"; check (Option.is_none (position development ordinary_includes)) "ordinary sources exclude development dependencies"; diff --git a/tests/rewatch_ounit_tests/compiler_info_tests.ml b/tests/rewatch_ounit_tests/compiler_info_tests.ml index ad60f987a05..70a7768e1e8 100644 --- a/tests/rewatch_ounit_tests/compiler_info_tests.ml +++ b/tests/rewatch_ounit_tests/compiler_info_tests.ml @@ -31,15 +31,21 @@ let tests = check (not (Compiler_info.needs_clean initial config)) "a package without an earlier build is not spuriously cleaned"; + write + (File_util.path_of_parts root ["lib"; "rescript"; ".compiler.log"]) + "failed build"; + check + (not (Compiler_info.needs_clean initial config)) + "a log without compiler information is not cleaned"; Compiler_info.write_package initial config; - let marker = File_util.path_of_parts root ["lib"; "ocaml"; "marker"] in + let marker = File_util.path_of_parts root ["lib"; "rescript"; "marker"] in write marker "keep"; check (not (Compiler_info.needs_clean initial config)) "matching compiler information is retained"; check (Sys.file_exists marker) "matching artifacts remain"; let info_path = - File_util.path_of_parts root ["lib"; "bs"; "compiler-info.json"] + File_util.path_of_parts root ["lib"; "rescript"; "compiler-info.json"] in Unix.utimes info_path 1_000_000_000. 1_000_000_000.; Compiler_info.write_package initial config; @@ -99,6 +105,34 @@ let tests = "missing metadata invalidates an existing legacy build"; Compiler_info.clean_package config; check (not (Sys.file_exists old_log)) "legacy build artifacts are removed"); + with_temp_dir (fun root -> + let config = config root in + let context = context root config [] in + let legacy_ast = + File_util.path_of_parts root ["lib"; "bs"; "src"; "A.ast"] + in + write legacy_ast "old build"; + check + (Compiler_info.needs_clean context config) + "a lib/bs of an earlier version invalidates the build"; + Compiler_info.clean_package config; + check + (not (Sys.file_exists (Filename.dirname (Filename.dirname legacy_ast)))) + "the first build with lib/rescript removes lib/bs"); + with_temp_dir (fun root -> + let config = config root in + let context = context root config [] in + Compiler_info.write_package context config; + check + (not (Compiler_info.needs_clean context config)) + "a current build is kept"; + (* A build of an earlier version after this one, such as on another + branch, leaves lib/ocaml next to current compiler information. *) + let legacy_cmi = File_util.path_of_parts root ["lib"; "ocaml"; "A.cmi"] in + write legacy_cmi "old build"; + check + (Compiler_info.needs_clean context config) + "a lib/ocaml of an earlier version invalidates a current build"); with_temp_dir (fun root -> let dependency = config root in let bsc = Filename.concat root "bsc.exe" in @@ -130,7 +164,7 @@ let tests = ~package_output_specs:commonjs in Compiler_info.write_package initial dependency; - let marker = File_util.path_of_parts root ["lib"; "ocaml"; "marker"] in + let marker = File_util.path_of_parts root ["lib"; "rescript"; "marker"] in write marker "keep"; let changed = Compiler_info.make_context ~compiler_path:bsc diff --git a/tests/rewatch_ounit_tests/compiler_process_tests.ml b/tests/rewatch_ounit_tests/compiler_process_tests.ml index 5e13eac975b..20738210c73 100644 --- a/tests/rewatch_ounit_tests/compiler_process_tests.ml +++ b/tests/rewatch_ounit_tests/compiler_process_tests.ml @@ -2,187 +2,284 @@ open OUnit2 let check condition message = assert_bool message condition +let succeeded = Process.{status = Unix.WEXITED 0; stdout = ""; stderr = ""} +let failed = Process.{status = Unix.WEXITED 1; stdout = ""; stderr = "error"} + +(* Runs [action] in a build that holds ASTs and interfaces as the build system + does. *) +let in_build action = + Build_file_store.set_held_writes Compiler_process.is_held; + Fun.protect + ~finally:(fun () -> Build_file_store.set_held_writes (fun _ -> false)) + (fun () -> Build_file_store.with_build action) + let publication_tests _context = Test_support.with_temp_dir "rewatch-compiler-process-" (fun root -> - let build_dir = Filename.concat root "build" in - let ocaml_dir = Filename.concat root "ocaml" in - File_util.ensure_dir build_dir; - File_util.ensure_dir ocaml_dir; + let artifact_dir = Filename.concat root "lib/rescript" in + let path extension = Filename.concat artifact_dir ("Ns." ^ extension) in + File_util.ensure_dir artifact_dir; + in_build (fun () -> + let namespace_task = + Compiler_process.namespace_task ~runtime:"unused" ~artifact_dir + ~entry:None ~package_dirty:true ~force:false "Ns" [] + |> Option.get + in + (* The compiler wrote an interface, but no implementation. *) + Build_file_store.write (path "cmi") "new cmi"; + match + Compiler_scheduler.capture_publication (fun () -> + namespace_task.Compiler_scheduler.publish succeeded) + with + | Compiler_scheduler.Failed_after_cmi_publication + {cmi_change = Compiler_scheduler.Cmi_changed; _} -> + assert_equal "new cmi" + (File_util.read_file (path "cmi")) + ~msg: + "namespace publication must publish the changed CMI before a \ + later artifact is found missing" + | _ -> + assert_failure + "namespace publication must report a changed CMI when a later \ + artifact is missing")); + Test_support.with_temp_dir "rewatch-namespace-retry-" (fun root -> + let artifact_dir = Filename.concat root "lib/rescript" in + let path extension = Filename.concat artifact_dir ("Ns." ^ extension) in + File_util.ensure_dir artifact_dir; List.iter - (fun extension -> - Test_support.write_file - (Filename.concat build_dir ("Ns." ^ extension)) - ("new " ^ extension)) + (fun extension -> Test_support.write_file (path extension) "old") ["cmi"; "cmj"; "cmt"]; - File_util.ensure_dir (Filename.concat ocaml_dir "Ns.cmj"); - let namespace_task = - Compiler_process.namespace_task ~runtime:"unused" ~build_dir ~ocaml_dir - ~entry:None ~package_dirty:true ~force:false "Ns" [] - |> Option.get - in - let result = - Process.{status = Unix.WEXITED 0; stdout = ""; stderr = ""} + let task ~package_dirty ~force = + Compiler_process.namespace_task ~runtime:"unused" ~artifact_dir + ~entry:None ~package_dirty ~force "Ns" [] in - match - Compiler_scheduler.capture_publication (fun () -> - namespace_task.Compiler_scheduler.publish result) - with - | Compiler_scheduler.Failed_after_cmi_publication - {cmi_change = Compiler_scheduler.Cmi_changed; _} -> - assert_equal "new cmi" - (File_util.read_file (Filename.concat ocaml_dir "Ns.cmi")) - ~msg: - "namespace publication must retain the changed CMI before a later \ - artifact copy fails" - | _ -> - assert_failure - "namespace publication must report a changed CMI across a later \ - artifact-copy failure"); - Test_support.with_temp_dir "rewatch-namespace-retry-" (fun root -> - let build_dir = Filename.concat root "build" in - let ocaml_dir = Filename.concat root "ocaml" in - File_util.ensure_dir build_dir; - File_util.ensure_dir ocaml_dir; - List.iter - (fun extension -> - Test_support.write_file - (Filename.concat ocaml_dir ("Ns." ^ extension)) - (if extension = "mlmap" then "old map\n" else "old artifact")) - ["cmi"; "cmj"; "cmt"; "mlmap"]; check - (Option.is_some - (Compiler_process.namespace_task ~runtime:"unused" ~build_dir - ~ocaml_dir ~entry:None ~package_dirty:false ~force:false "Ns" [])) - "a published namespace map that differs from membership is rebuilt"; - Test_support.write_file - (Filename.concat ocaml_dir "Ns.mlmap") - "randjbuildsystem\n"; + (Option.is_some (task ~package_dirty:false ~force:false)) + "a namespace map that differs from membership is rebuilt"; + check + (not (Sys.file_exists (path "cmt"))) + "a namespace to compile loses its typed tree until it is published"; + (* A build killed after it wrote the map but before it compiled it. *) check - (Option.is_some - (Compiler_process.namespace_task ~runtime:"unused" ~build_dir - ~ocaml_dir ~entry:None ~package_dirty:false ~force:true "Ns" [])) - "retained namespace publication dirtiness forces a retry") + (Option.is_some (task ~package_dirty:false ~force:false)) + "a namespace without its typed tree is compiled again"; + (* The compile of the new map publishes its typed tree. *) + Test_support.write_file (path "cmt") "new"; + check + (Option.is_none (task ~package_dirty:false ~force:false)) + "a current namespace map with its outputs is not rebuilt"; + check + (Option.is_some (task ~package_dirty:false ~force:true)) + "retained namespace publication dirtiness forces a retry"; + in_build (fun () -> + let namespace_task = + Option.get (task ~package_dirty:true ~force:false) + in + Build_file_store.write (path "cmi") "failed cmi"; + (try + ignore (namespace_task.Compiler_scheduler.publish failed); + assert_failure "a failed namespace compile raises" + with Compiler_scheduler.Build_failure _ -> ()); + assert_equal "old" + (File_util.read_file (path "cmi")) + ~msg:"a failed namespace compile keeps the previous interface"); + check + (Option.is_some (task ~package_dirty:false ~force:false)) + "a failed namespace compile is retried by the next build") -(* Publishing a module keeps the interface and .cmj that its dependents read - in the build file store, and releases the files that nothing reads again, - including the copies it makes. *) +(* Publishing a module writes its interface only when it changed, so that an + unchanged interface keeps the modification time its dependents compare + with, and releases from the build file store what nothing reads again. *) let publication_releases_files_tests _context = Test_support.with_temp_dir "rewatch-publication-store-" (fun root -> Test_support.write_file (Filename.concat root "rescript.json") {|{"name":"publish","sources":"src","package-specs":{"module":"commonjs","in-source":true},"suffix":".js"}|}; let config = Config.load_root root in - let build_dir = Filename.concat root "lib/bs" in - let ocaml_dir = Filename.concat root "lib/ocaml" in - let path = "src/A.res" in - let source = Filename.concat root path in - let built extension = Filename.concat build_dir ("src/A." ^ extension) in - let published extension = Filename.concat ocaml_dir ("A." ^ extension) in - let output = + let artifact_dir = Filename.concat root "lib/rescript" in + let artifact name = Filename.concat artifact_dir name in + let output path = Build_artifacts.generated_js_path config path (List.hd config.package_specs) in - File_util.ensure_dir (Filename.concat build_dir "src"); - File_util.ensure_dir ocaml_dir; - Test_support.write_file source "let value = 1\n"; - Build_file_store.with_build (fun () -> + File_util.ensure_dir artifact_dir; + File_util.ensure_dir (Filename.concat root "src"); + let publish ?(has_interface = false) path = + Compiler_process.publish ~artifact_dir ~is_local:true ~config + ~has_interface ~source_kind:Source.Implementation path succeeded + in + Test_support.write_file (artifact "Same.cmi") "same interface"; + Unix.utimes (artifact "Same.cmi") 1_000_000_000. 1_000_000_000.; + Test_support.write_file (artifact "Kept.cmi") "kept interface"; + Test_support.write_file (artifact "Failed.cmi") "previous interface"; + in_build (fun () -> List.iter - (fun extension -> - Build_file_store.write (built extension) ("built " ^ extension)) - ["cmi"; "cmj"; "cmt"; "ast"]; - Build_file_store.write output "js"; - ignore (Build_file_store.read source); - ignore - (Compiler_process.publish ~build_dir ~ocaml_dir ~is_local:true - ~config ~has_interface:false ~source_kind:Source.Implementation - path - Process.{status = Unix.WEXITED 0; stdout = ""; stderr = ""}); + (fun name -> + Build_file_store.write (artifact (name ^ ".cmi")) ("new " ^ name); + Build_file_store.write (artifact (name ^ ".cmj")) "code"; + Build_file_store.write (artifact (name ^ ".cmt")) "typed tree") + ["A"]; + (* The compile read the AST that its parse published. *) + Test_support.write_file (artifact "A.ast") "ast"; + ignore (Build_file_store.read (artifact "A.ast")); + Build_file_store.write (output "src/A.res") "js"; + check + (not (Sys.file_exists (artifact "A.cmi"))) + "an interface is held until its compile is published"; + (* A build killed now leaves no typed tree that would mark the + module compiled with its previous interface. *) + check + (not (Sys.file_exists (artifact "A.cmt"))) + "a typed tree is held until its compile is published"; + check + ((publish "src/A.res").cmi_change = Compiler_scheduler.Cmi_changed) + "a new interface is a change"; + assert_equal "new A" (File_util.read_file (artifact "A.cmi")); + assert_equal "typed tree" (File_util.read_file (artifact "A.cmt")); List.iter (fun (path, kept) -> check (Option.is_some (Build_file_store.cached path) = kept) (path ^ if kept then " is kept" else " is released")) [ - (published "cmi", true); - (published "cmj", true); - (published "cmt", false); - (published "res", false); - (built "cmi", false); - (built "cmj", false); - (built "cmt", false); - (built "ast", false); - (Filename.concat build_dir path, false); - (source, false); - (output, false); - ]); - (* An implementation with an interface is compiled with -bs-read-cmi, - which reads its interface's .cmi in lib/bs again. *) - let interface_path = "src/B.res" in - let built_cmi = Filename.concat build_dir "src/B.cmi" in - Test_support.write_file - (Filename.concat root interface_path) - "let b = 1\n"; - Build_file_store.with_build (fun () -> - List.iter - (fun extension -> - Build_file_store.write - (Filename.concat build_dir ("src/B." ^ extension)) - ("built " ^ extension)) - ["cmi"; "cmj"; "cmt"]; - ignore - (Compiler_process.publish ~build_dir ~ocaml_dir ~is_local:true - ~config ~has_interface:true ~source_kind:Source.Implementation - interface_path - Process.{status = Unix.WEXITED 0; stdout = ""; stderr = ""}); + (artifact "A.cmi", true); + (artifact "A.cmj", true); + (artifact "A.cmt", false); + (artifact "A.ast", false); + (output "src/A.res", false); + ]; + Build_file_store.write (artifact "Same.cmi") "same interface"; + Build_file_store.write (artifact "Same.cmj") "code"; check - (Option.is_none (Build_file_store.cached built_cmi)) - "the interface read again is released"); - check - (File_util.read_file (Filename.concat ocaml_dir "A.cmt") = "built cmt") - "the typed tree is published") + ((publish "src/Same.res").cmi_change + = Compiler_scheduler.Cmi_unchanged) + "an identical interface is no change"; + check + ((Unix.stat (artifact "Same.cmi")).st_mtime = 1_000_000_000.) + "an identical interface keeps its modification time"; + (* The compiler does not write an interface identical to the one on + disk. *) + Build_file_store.write (artifact "Kept.cmj") "code"; + check + ((publish "src/Kept.res").cmi_change + = Compiler_scheduler.Cmi_unchanged) + "an interface the compiler did not rewrite is no change"; + Test_support.write_file (artifact "Failed.ast") "ast"; + Build_file_store.write (artifact "Failed.cmi") "failed interface"; + Build_file_store.write (artifact "Failed.cmt") "partial typed tree"; + Compiler_process.discard_compile ~artifact_dir ~config + "src/Failed.res"; + check + (Build_file_store.read (artifact "Failed.cmi") + = Some "previous interface") + "a failed compile leaves the previous interface"; + check + ((Unix.stat (artifact "Failed.ast")).st_mtime < 2.) + "a failed compile dates its AST back, so the next build compiles \ + it again"; + (* Another process holds the typed tree's place. *) + Unix.mkdir (artifact "Blocked.cmt") 0o755; + Test_support.write_file (artifact "Blocked.ast") "ast"; + Build_file_store.write (artifact "Blocked.cmi") "failed interface"; + Build_file_store.write (artifact "Blocked.cmt") "partial typed tree"; + Compiler_process.discard_compile ~artifact_dir ~config + "src/Blocked.res"; + check + (Option.is_none (Build_file_store.cached (artifact "Blocked.cmt"))) + "a typed tree that could not be published is dropped"; + check + (not (Sys.file_exists (artifact "Blocked.cmi"))) + "a failed compile whose typed tree cannot be published still \ + leaves the interface alone"); + assert_equal "previous interface" + (File_util.read_file (artifact "Failed.cmi")); + assert_equal "partial typed tree" + (File_util.read_file (artifact "Failed.cmt")) + ~msg:"a failed compile publishes its partial typed tree for editors") + +(* An artifact is renamed into place, and written in place when the rename + fails, as on Windows while an editor has the file open. Here a read-only + artifact directory makes the rename fail while the file stays writable. *) +let in_place_fallback_tests _context = + if (not Sys.win32) && Unix.getuid () <> 0 then + Test_support.with_temp_dir "rewatch-publication-fallback-" (fun root -> + let artifact_dir = Filename.concat root "lib/rescript" in + let ast = Filename.concat artifact_dir "A.ast" in + Test_support.write_file ast "previous AST"; + Unix.chmod artifact_dir 0o555; + Fun.protect + ~finally:(fun () -> Unix.chmod artifact_dir 0o755) + (fun () -> + in_build (fun () -> + Build_file_store.write ast "new AST"; + Compiler_process.publish_parse ~artifact_dir "src/A.res")); + assert_equal "new AST" (File_util.read_file ast) + ~msg:"a file that cannot be renamed into place is written in place"; + check + (Array.for_all + (fun name -> + not + (String.starts_with ~prefix:File_util.atomic_write_prefix name)) + (Sys.readdir artifact_dir)) + "the fallback leaves no temporary file") (* A parse that printed warnings is left for the build to publish after it registers the cleanup that repeats them, so that a build interrupted before - then does not leave behind an AST whose warnings the next build skips. *) + then does not leave behind an AST whose warnings the next build skips. A + parse that failed leaves the previous AST. *) let parse_publication_tests _context = Test_support.with_temp_dir "rewatch-parse-publication-" (fun root -> Test_support.write_file (Filename.concat root "rescript.json") {|{"name":"parse","sources":"src","package-specs":{"module":"commonjs","in-source":true},"suffix":".js"}|}; let config = Config.load_root root in - let build_dir = Filename.concat root "lib/bs" in - let ocaml_dir = Filename.concat root "lib/ocaml" in - File_util.ensure_dir ocaml_dir; + let artifact_dir = Filename.concat root "lib/rescript" in + File_util.ensure_dir artifact_dir; Test_support.write_file (Filename.concat root "src/Clean.res") "let value = 1\n"; Test_support.write_file (Filename.concat root "src/Warns.res") "let f = (. x) => x\n"; - let paths = ["src/Clean.res"; "src/Warns.res"] in - let results = - paths - |> List.map (fun path -> (build_dir, ocaml_dir, config, path)) - |> Compiler_process.run_parses - in - List.iter2 - (fun path (result : Process.result) -> - check (Process.succeeded result) (path ^ " parses"); - let warns = path = "src/Warns.res" in - check - (result.stderr <> "" = warns) - (path ^ if warns then " prints a warning" else " prints nothing"); - List.iter - (fun published -> - check - (Sys.file_exists published = not warns) - (published - ^ if warns then " is not published" else " is published")) - [ - Build_artifacts.published_ast_path ~ocaml_dir path; - Filename.concat ocaml_dir (Filename.basename path); - ]) - paths results) + Test_support.write_file + (Filename.concat root "src/Broken.res") + "let x =\n"; + let ast path = Build_artifacts.ast_path ~artifact_dir path in + Test_support.write_file (ast "src/Broken.res") "previous AST"; + let paths = ["src/Clean.res"; "src/Warns.res"; "src/Broken.res"] in + in_build (fun () -> + let results = + paths + |> List.map (fun path -> (artifact_dir, config, path)) + |> Compiler_process.run_parses + in + List.iter2 + (fun path (result : Process.result) -> + match path with + | "src/Clean.res" -> + check + (Process.succeeded result && result.stderr = "") + "a clean parse prints nothing"; + check (Sys.file_exists (ast path)) "a clean parse is published" + | "src/Warns.res" -> + check + (Process.succeeded result && result.stderr <> "") + "a parse with warnings prints them"; + check + (not (Sys.file_exists (ast path))) + "a parse with warnings is not published yet"; + check + (Option.is_some (Build_file_store.cached (ast path))) + "the build reads the unpublished AST"; + Compiler_process.publish_parse ~artifact_dir path; + check + (Sys.file_exists (ast path)) + "the build publishes it once the cleanup is registered" + | _ -> + check (not (Process.succeeded result)) "a broken source fails"; + assert_equal "previous AST" + (File_util.read_file (ast path)) + ~msg:"a failed parse leaves the previous AST") + paths results)) let restore_environment name previous = match previous with @@ -376,6 +473,7 @@ let tests = "publication" >:: publication_tests; "publication_releases_files" >:: publication_releases_files_tests; "parse_publication" >:: parse_publication_tests; + "in_place_fallback" >:: in_place_fallback_tests; "domain_ppx_cancellation" >:: domain_ppx_cancellation_test; "escaped_exception" >:: escaped_exception_test; "domain_execution" >:: domain_execution_test; diff --git a/tests/rewatch_ounit_tests/compiler_scheduler_tests.ml b/tests/rewatch_ounit_tests/compiler_scheduler_tests.ml index 5c6adb73cfc..be80d49498a 100644 --- a/tests/rewatch_ounit_tests/compiler_scheduler_tests.ml +++ b/tests/rewatch_ounit_tests/compiler_scheduler_tests.ml @@ -39,9 +39,8 @@ let tests = "compiler_scheduler_tests" >:: fun _context -> with_single_domain (fun () -> with_temp_dir (fun root -> - let ocaml_dir = Build_artifacts.lib_path root "ocaml" in - File_util.ensure_dir ocaml_dir; - File_util.ensure_dir (Build_artifacts.lib_path root "bs"); + let artifact_dir = Build_artifacts.artifact_dir root in + File_util.ensure_dir artifact_dir; Compiler_log.initialize root; let a_source = source "A" in let b_source = source "B" in @@ -58,15 +57,15 @@ let tests = let c_state = Build_state.find_exn build_state "C" in a_state.compile_dirty <- true; c_state.compile_dirty <- true; - let a_cmi = Filename.concat ocaml_dir "A.cmi" in - let b_cmi = Filename.concat ocaml_dir "B.cmi" in - let c_cmi = Filename.concat ocaml_dir "C.cmi" in - let a_ast = Filename.concat ocaml_dir "A.ast" in + let a_cmi = Filename.concat artifact_dir "A.cmi" in + let b_cmi = Filename.concat artifact_dir "B.cmi" in + let c_cmi = Filename.concat artifact_dir "C.cmi" in + let a_ast = Filename.concat artifact_dir "A.ast" in write_file a_cmi "old interface"; write_file b_cmi "dependent interface"; Test_support.write_ast_header a_ast ~dependencies:[] ~source:"src/A.res"; - let compile_assets = Compile_assets.create [ocaml_dir] in + let compile_assets = Compile_assets.create [artifact_dir] in let fail_a_publication = ref true in let b_compilations = ref 0 in let c_compilations = ref 0 in @@ -144,9 +143,9 @@ let tests = in check first_failed "a later publication failure is reported normally"; check - (not (Sys.file_exists a_ast)) + (Sys.file_exists a_ast && (Unix.stat a_ast).st_mtime < 2.) "failed completion invalidates durable freshness for a later \ - process"; + process, keeping the AST that this process may still compile"; check b_state.compile_dirty "a published CMI change survives a later publication failure"; check (!b_compilations = 0) @@ -171,8 +170,12 @@ let tests = Build_state.find_exn interrupted_state "Interrupted" in interrupted_module.compile_dirty <- true; - let interrupted_ast = Filename.concat ocaml_dir "Interrupted.ast" in - let interrupted_cmi = Filename.concat ocaml_dir "Interrupted.cmi" in + let interrupted_ast = + Filename.concat artifact_dir "Interrupted.ast" + in + let interrupted_cmi = + Filename.concat artifact_dir "Interrupted.cmi" + in let interrupted_hook_root = Filename.concat root "interrupted-hook" in Unix.mkdir interrupted_hook_root 0o755; Test_support.write_ast_header interrupted_ast ~dependencies:[] @@ -215,7 +218,7 @@ let tests = "child-started") then raise Exit)) ~warning_state:(Warning_state.create ()) - ~compile_assets:(Compile_assets.create [ocaml_dir]) + ~compile_assets:(Compile_assets.create [artifact_dir]) ~build_state:interrupted_state ~candidates:[interrupted_candidate] ~mark_compiled:(fun () -> ()) @@ -227,7 +230,7 @@ let tests = in check hook_interrupted "a running post-build hook can be interrupted"; check - (not (Sys.file_exists interrupted_ast)) + ((Unix.stat interrupted_ast).st_mtime < 2.) "interrupted post-build invalidates persistent compiler freshness"; let marker = Failure "copy after CMI failed" in match diff --git a/tests/rewatch_ounit_tests/config_tests.ml b/tests/rewatch_ounit_tests/config_tests.ml index 48026a57bdd..79a10b32a2f 100644 --- a/tests/rewatch_ounit_tests/config_tests.ml +++ b/tests/rewatch_ounit_tests/config_tests.ml @@ -281,12 +281,12 @@ let compiler_job_tests = write_file path {|{"name":"compiler-jobs","gentypeconfig":{}}|}; let config = Config.load path in let source = Filename.concat root "src/A.res" in - let build_dir = Filename.concat config.root "lib/bs" in - File_util.ensure_dir build_dir; + let artifact_dir = Filename.concat config.root "lib/rescript" in + File_util.ensure_dir artifact_dir; File_util.ensure_dir (Filename.dirname source); write_file source "let value = 1\n"; let parse_job = - Compiler_process.parse_request ~build_dir ~config "src/A.res" + Compiler_process.parse_request ~artifact_dir ~config "src/A.res" in let module_ = Source. @@ -298,7 +298,7 @@ let compiler_job_tests = } in let compile_job = - Compiler_process.compile_request ~build_dir ~config + Compiler_process.compile_request ~artifact_dir ~config ~common_args: (Compiler_args.compiler_common_arguments ~project_root:config.root ~config ~runtime:"runtime" ~dependency_dirs:[] ~watch:false @@ -312,7 +312,7 @@ let compiler_job_tests = in check (parse_job.Compiler_process.cwd = compile_job.Compiler_process.cwd - && parse_job.cwd = build_dir) + && parse_job.cwd = artifact_dir) "parser and compiler jobs derive the same canonical working directory"; check (argument_after "-bs-project-root" compile_job.args = Some config.root) diff --git a/tests/rewatch_ounit_tests/file_util_tests.ml b/tests/rewatch_ounit_tests/file_util_tests.ml index 40d91e9f199..f0cff9b13d8 100644 --- a/tests/rewatch_ounit_tests/file_util_tests.ml +++ b/tests/rewatch_ounit_tests/file_util_tests.ml @@ -9,15 +9,6 @@ let write_file path contents = ~finally:(fun () -> close_out_noerr channel) (fun () -> output_string channel contents) -let descriptor_count () = - try Some (Array.length (Sys.readdir "/proc/self/fd")) - with Sys_error _ -> None - -let check_descriptor_count before message = - match (before, descriptor_count ()) with - | Some before, Some after -> check (before = after) message - | None, _ | _, None -> () - let tests = "file_util_tests" >:: fun _context -> let root = Filename.temp_file "rewatch-file-util-" "" in @@ -36,16 +27,6 @@ let tests = check (not (File_util.exists missing)) "a missing path should be reported as absent"; - check - (File_util.files_equal first second) - "equal file contents should compare equal"; - write_file second "different"; - check - (not (File_util.files_equal first second)) - "different file contents should not compare equal"; - check - (not (File_util.files_equal missing first)) - "a missing file should not compare equal"; (* The watch shutdown protocol and atomic saves remove or rename files while the watcher may be reading them. *) let held = Filename.concat root "held" in @@ -71,49 +52,6 @@ let tests = check (contents = "streamed") "whole-file reads consume streams whose initial length is zero"; File_util.remove_file fifo); - let large_source = Filename.concat root "large-source" in - let large_copy = Filename.concat root "large-copy" in - let large_contents = - String.init 150_000 (fun index -> Char.chr (index mod 251)) - in - write_file large_source large_contents; - File_util.copy_existing_file large_source large_copy; - check - (File_util.files_equal large_source large_copy) - "streaming copies preserve files spanning multiple buffer reads"; - (* A copy that fails before writing leaves the previous file alone, and - one that fails while writing removes its partial destination, so a - truncated .cmi or .cmj is never left for the next build. *) - let failed_root = Filename.concat root "failed-copy" in - let unreadable = Filename.concat failed_root "unreadable" in - let published = Filename.concat failed_root "Published.cmj" in - File_util.ensure_dir unreadable; - write_file published "previous"; - let copy_fails source = - try - File_util.copy_existing_file source published; - false - with Sys_error _ | Unix.Unix_error _ -> true - in - check (copy_fails unreadable) "copying a directory fails"; - check - (File_util.read_file published = "previous") - "a copy that fails before writing leaves the destination unchanged"; - (* Reading /proc/self/mem at offset 0 fails after the file opened. *) - if Sys.file_exists "/proc/self/mem" then ( - check (copy_fails "/proc/self/mem") "a failing read fails the copy"; - check - (not (Sys.file_exists published)) - "a copy that fails while writing removes its partial destination"); - File_util.remove_tree failed_root; - let changed_contents = Bytes.of_string large_contents in - Bytes.set changed_contents (Bytes.length changed_contents - 1) 'x'; - write_file large_copy (Bytes.to_string changed_contents); - check - (not (File_util.files_equal large_source large_copy)) - "chunk comparison detects a difference after the first buffer"; - File_util.remove_file large_source; - File_util.remove_file large_copy; let concurrent_root = Filename.concat root "concurrent" in let start = Atomic.make false in let failures = ref [] in @@ -159,40 +97,6 @@ let tests = check (Option.is_none (File_util.modification_time missing)) "a missing file should not have a modification time"; - let optional_copy = Filename.concat root "optional-copy" in - File_util.copy_optional_existing_file first optional_copy; - check - (File_util.read_file optional_copy = "same") - "an available optional artifact should be copied"; - File_util.copy_optional_existing_file missing optional_copy; - check - (not (Sys.file_exists optional_copy)) - "a stale optional destination should be removed when its source is \ - absent"; - let missing_destination = Test_support.path root "absent/optional-copy" in - let descriptors_before_failed_copies = descriptor_count () in - for _ = 1 to 32 do - let destination_failure_is_reported = - try - File_util.copy_optional_existing_file first missing_destination; - false - with Sys_error _ | Unix.Unix_error _ -> true - in - check destination_failure_is_reported - "an optional copy must not hide destination failures" - done; - check_descriptor_count descriptors_before_failed_copies - "failed destination acquisition should close the source"; - let missing_source_failure_is_reported = - try - ignore - (File_util.copy_file_if_different missing - (Filename.concat root "missing-copy")); - false - with Sys_error _ | Unix.Unix_error _ -> true - in - check missing_source_failure_is_reported - "a conditional copy must report a missing source"; let atomic = Filename.concat root "atomic" in write_file atomic "previous"; if not Sys.win32 then Unix.chmod atomic 0o640; @@ -207,7 +111,8 @@ let tests = check (Sys.readdir root |> Array.to_list |> List.for_all (fun name -> - not (String.starts_with ~prefix:".rewatch-write-" name))) + not (String.starts_with ~prefix:File_util.atomic_write_prefix name)) + ) "successful atomic writes should not leave temporary files"; if (not Sys.win32) && Sys.file_exists "/dev/full" then check @@ -216,37 +121,6 @@ let tests = false with Sys_error _ | Unix.Unix_error _ -> true) "a failure while flushing or closing an output file must be reported"; - Sys.remove first; - write_file first "same"; - if not Sys.win32 then ( - let unreadable = Filename.concat root "unreadable" in - write_file unreadable "same"; - Unix.chmod unreadable 0o000; - Fun.protect - ~finally:(fun () -> Unix.chmod unreadable 0o600) - (fun () -> - let second_open_fails = - try - let channel = open_in_bin unreadable in - close_in channel; - false - with Sys_error _ -> true - in - if second_open_fails then ( - let descriptors_before_comparisons = descriptor_count () in - for _ = 1 to 32 do - let comparison_failure_is_reported = - try - ignore (File_util.files_equal first unreadable); - false - with Sys_error _ | Unix.Unix_error _ -> true - in - check comparison_failure_is_reported - "a comparison must not hide input failures" - done; - check_descriptor_count descriptors_before_comparisons - "failed second-file acquisition should close the first file")); - File_util.remove_file unreadable); check (List.sort String.compare (File_util.files_under root) = List.sort String.compare [atomic; first; second]) diff --git a/tests/rewatch_ounit_tests/native_watcher_tests.ml b/tests/rewatch_ounit_tests/native_watcher_tests.ml index b98bfccf352..a977f6b0c3a 100644 --- a/tests/rewatch_ounit_tests/native_watcher_tests.ml +++ b/tests/rewatch_ounit_tests/native_watcher_tests.ml @@ -20,13 +20,13 @@ let tests = let replaced_nested = root ^ "-replaced-nested" in let source_lib = Filename.concat source "lib" in let artifact_lib = Filename.concat root "lib" in - let artifact_bs = Filename.concat artifact_lib "bs" in + let artifact_dir = Filename.concat artifact_lib "rescript" in Fun.protect (fun () -> Unix.mkdir source 0o700; Unix.mkdir source_lib 0o700; Unix.mkdir artifact_lib 0o700; - Unix.mkdir artifact_bs 0o700; + Unix.mkdir artifact_dir 0o700; let paths = [Native_watcher.{directory = root; recursive = true}] in let identity_failure _ = Error "injected identity failure" in (match @@ -96,7 +96,7 @@ let tests = (fun () -> check (Native_watcher.For_test.handle_count watcher = 4) - "valid lib source directories are watched but lib/bs is not"; + "valid lib source directories are watched but lib/rescript is not"; Native_watcher.For_test.queue_change watcher; Native_watcher.For_test.queue_error watcher "injected failure"; (match @@ -182,7 +182,7 @@ let tests = ~finally:(fun () -> (try Unix.rmdir nested with Unix.Unix_error _ -> ()); (try Unix.rmdir replaced_nested with Unix.Unix_error _ -> ()); - (try Unix.rmdir artifact_bs with Unix.Unix_error _ -> ()); + (try Unix.rmdir artifact_dir with Unix.Unix_error _ -> ()); (try Unix.rmdir artifact_lib with Unix.Unix_error _ -> ()); (try Unix.rmdir source_lib with Unix.Unix_error _ -> ()); (try Unix.rmdir source with Unix.Unix_error _ -> ()); diff --git a/tests/rewatch_ounit_tests/test_support.ml b/tests/rewatch_ounit_tests/test_support.ml index 3ccaa3202f8..3dffd349e09 100644 --- a/tests/rewatch_ounit_tests/test_support.ml +++ b/tests/rewatch_ounit_tests/test_support.ml @@ -9,6 +9,10 @@ let write_file path contents = ~finally:(fun () -> close_out_noerr channel) (fun () -> output_string channel contents) +(* Copies contents only; callers set the mode they need. *) +let copy_file source destination = + write_file destination (File_util.read_file source) + let write_ast_header path ~dependencies ~source = File_util.ensure_dir (Filename.dirname path); let channel = open_out_bin path in diff --git a/tests/rewatch_ounit_tests/unit_tests.ml b/tests/rewatch_ounit_tests/unit_tests.ml index 96463f3fca8..7d14ffe3d4e 100644 --- a/tests/rewatch_ounit_tests/unit_tests.ml +++ b/tests/rewatch_ounit_tests/unit_tests.ml @@ -502,7 +502,7 @@ let platform_tests _context = let command = if Sys.win32 then "worker.exe" else "worker" in Unix.mkdir (Filename.concat first command) 0o755; let executable = Filename.concat second command in - File_util.copy_existing_file test_executable executable; + Test_support.copy_file test_executable executable; Unix.chmod executable 0o755; let previous_path = Sys.getenv_opt "PATH" in let separator = if Sys.win32 then ";" else ":" in @@ -525,7 +525,7 @@ let platform_tests _context = "an explicit current-directory executable does not use PATH"; if Sys.win32 then ( let cwd_executable = Filename.concat path_root "current.exe" in - File_util.copy_existing_file test_executable cwd_executable; + Test_support.copy_file test_executable cwd_executable; check (Platform.resolve_program ~cwd:path_root "current" = "current") "Windows executable lookup does not search the current directory") @@ -540,8 +540,8 @@ let platform_tests _context = let trimmed_executable = Filename.concat trimmed_directory command in - File_util.copy_existing_file test_executable literal_executable; - File_util.copy_existing_file test_executable trimmed_executable; + Test_support.copy_file test_executable literal_executable; + Test_support.copy_file test_executable trimmed_executable; Unix.chmod literal_executable 0o755; Unix.chmod trimmed_executable 0o755; Unix.putenv "PATH" literal_directory; @@ -791,14 +791,16 @@ let graph_and_diagnostic_tests _context = "dependency paths are canonicalized" | None -> failwith "dependency symlink was not resolved")); Test_support.with_temp_dir "rewatch-compiler-log-" (fun root -> - File_util.ensure_dir (Build_artifacts.lib_path root "ocaml"); + File_util.ensure_dir (Build_artifacts.artifact_dir root); Compiler_log.initialize root; Compiler_log.append root "plain \027[1;31mred\027[0m text"; Compiler_log.finalize root; check (String_util.contains (File_util.read_file - (File_util.path_of_parts root ["lib"; "ocaml"; ".compiler.log"])) + (Filename.concat + (Build_artifacts.artifact_dir root) + ".compiler.log")) "plain red text") "published compiler logs strip ANSI sequences"); let decoded = @@ -878,8 +880,8 @@ let lock_tests _context = Sys.remove lock_root; Unix.mkdir lock_root 0o755; let lock_root = Unix.realpath lock_root in - let lock_dir = Filename.concat lock_root "lib" in - Unix.mkdir lock_dir 0o755; + let lock_dir = Build_artifacts.artifact_dir lock_root in + File_util.ensure_dir lock_dir; let lock = Filename.concat lock_dir "build.lock" in let takeover = lock ^ ".takeover" in let write_owner path owner = @@ -923,7 +925,7 @@ let lock_tests _context = "releasing a build lock twice is harmless"); check (not (Sys.file_exists lock)) "released build lock is removed"; let owner_executable = Filename.concat lock_root "rescript.exe" in - File_util.copy_existing_file test_executable owner_executable; + Test_support.copy_file test_executable owner_executable; if not Sys.win32 then Unix.chmod owner_executable 0o755; let owner_pid = Spawn.spawn ~prog:owner_executable diff --git a/tests/rewatch_ounit_tests/watcher_tests.ml b/tests/rewatch_ounit_tests/watcher_tests.ml index cfe4230ba0f..6c697fc48ff 100644 --- a/tests/rewatch_ounit_tests/watcher_tests.ml +++ b/tests/rewatch_ounit_tests/watcher_tests.ml @@ -263,7 +263,7 @@ let tests = with Exit -> true in check raised "build callback exception is preserved"; - let lock = Filename.concat root "lib/watch.lock" in + let lock = Filename.concat root "lib/rescript/watch.lock" in check (not (Sys.file_exists lock)) "watch lock is released when setup or the initial build fails"; From 805d621a5da50dc20ce3665980047ac638701d46 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Fri, 6 Nov 2026 13:36:13 +0000 Subject: [PATCH 2/3] Read compiled files from the flat lib/rescript in analysis and gentype Why: The tools found a module's compiled files through the nested lib/bs mirror of the sources and the source copies in lib/ocaml, which the previous commit removes. Each tool now looks a module up by its compiled file name: - analysis reads /lib/rescript/[-Ns].cmt, the stdlib's compiled files from /lib/rescript and its sources from the runtime package root, .sourcedirs.json from lib/rescript, and incremental files from lib/rescript/incremental; - reanalyze scans each package's lib/rescript, and its -cmt-root walk skips the editor's incremental directory; - gentype finds a dependency module's source directory in the header of its AST, read once per build, and maps a namespace module to its package root; it looks an imported module of the same package up as [-Ns].cmt, trying the compiler's spelling first, and reads typed trees through the build file store, which holds the one being compiled, without keeping them. Review: Why does the reanalyze snapshot move one line? The scan visited the nested source directories first and the build root last; one flat directory is scanned in name order. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Kbf3gGBR9g3DD93vrWbYzU Signed-off-by: Christoph Knittel --- analysis/bin/main.ml | 8 +- analysis/reanalyze/README.md | 2 +- analysis/reanalyze/src/paths.ml | 5 +- analysis/reanalyze/src/reanalyze.ml | 3 + analysis/src/build_system.ml | 7 +- analysis/src/cache.ml | 10 +- analysis/src/cli.ml | 2 +- analysis/src/cmt.ml | 2 +- analysis/src/find_files.ml | 67 +++++---- analysis/src/packages.ml | 16 ++- compiler/gentype/dune | 2 +- compiler/gentype/emit_js.ml | 4 +- compiler/gentype/import_path.ml | 30 ++-- compiler/gentype/import_path.mli | 5 +- compiler/gentype/module_resolver.ml | 132 ++++++++++++++---- compiler/gentype/paths.ml | 13 +- .../tests-namespaced-references/Makefile | 8 +- .../deadcode/expected/deadcode.txt | 2 +- 18 files changed, 217 insertions(+), 101 deletions(-) diff --git a/analysis/bin/main.ml b/analysis/bin/main.ml index 633a64cb8f6..cb1f2f57591 100644 --- a/analysis/bin/main.ml +++ b/analysis/bin/main.ml @@ -64,7 +64,7 @@ Options: createInterface: print to stdout the interface file for src/MyFile.res - ./rescript-editor-analysis.exe createInterface src/MyFile.res lib/bs/src/MyFile.cmi + ./rescript-editor-analysis.exe createInterface src/MyFile.res lib/rescript/MyFile.cmi format: print to stdout the formatted version of the provided file @@ -127,10 +127,10 @@ let main () = let uri = Uri.from_path root_path in match Packages.find_root ~uri (Hashtbl.create 0) with | Some (`Bs root_path) -> ( - match Build_system.get_lib_bs root_path with + match Build_system.get_artifact_dir root_path with | None -> print_endline "\"ERR\"" - | Some lib_bs -> - Cache.delete_cache (Cache.target_file_from_lib_bs lib_bs); + | Some artifact_dir -> + Cache.delete_cache (Cache.target_file_from_artifact_dir artifact_dir); print_endline "\"OK\"") | _ -> print_endline "\"ERR: Did not find root \"") | [_; "completion"; path; line; col; current_file] -> diff --git a/analysis/reanalyze/README.md b/analysis/reanalyze/README.md index 53a165be25b..d7c75c4fc06 100644 --- a/analysis/reanalyze/README.md +++ b/analysis/reanalyze/README.md @@ -17,7 +17,7 @@ Dead code analysis and other experimental analyses for ReScript. rescript-tools reanalyze -config # Run DCE analysis on specific CMT directory -rescript-tools reanalyze -dce-cmt path/to/lib/bs +rescript-tools reanalyze -dce-cmt path/to/lib/rescript # Run all analyses rescript-tools reanalyze -all diff --git a/analysis/reanalyze/src/paths.ml b/analysis/reanalyze/src/paths.ml index 6bd4df78f55..fc5635ce08a 100644 --- a/analysis/reanalyze/src/paths.ml +++ b/analysis/reanalyze/src/paths.ml @@ -133,14 +133,15 @@ type cmt_scan_entry = { This is a v2 extension produced by `rewatch` to support monorepos without requiring reanalyze-side package resolution. - The scan plan is a list of build roots (usually `/lib/bs`) relative to the project root, + The scan plan is a list of build roots (`/lib/rescript`) relative to the project root, plus a list of subdirectories (relative to that build root) to scan for `.cmt/.cmti`. + Build roots are flat, so the subdirectories are empty and each build root is scanned itself. If missing, returns the empty list and callers should fall back to legacy behavior. *) let read_cmt_scan () = let source_dirs_file = - ["lib"; "bs"; ".sourcedirs.json"] + ["lib"; "rescript"; ".sourcedirs.json"] |> List.fold_left Filename.concat run_config.bsb_project_root in let get_fn key fn json = diff --git a/analysis/reanalyze/src/reanalyze.ml b/analysis/reanalyze/src/reanalyze.ml index 27e6e87dfc6..62b18ad5f4d 100644 --- a/analysis/reanalyze/src/reanalyze.ml +++ b/analysis/reanalyze/src/reanalyze.ml @@ -15,6 +15,9 @@ let collect_cmt_file_paths ~cmt_root : string list = let skip_dir = let base = Filename.basename dir in base = "node_modules" || base = "_esy" + (* The editor's copies of compiled files. *) + || base = "incremental" + && Filename.basename (Filename.dirname dir) = "rescript" in if (not skip_dir) && Sys.file_exists abs_dir then if Sys.is_directory abs_dir then diff --git a/analysis/src/build_system.ml b/analysis/src/build_system.ml index 9dcb8f6dfc2..c1eecf4869f 100644 --- a/analysis/src/build_system.ml +++ b/analysis/src/build_system.ml @@ -40,9 +40,12 @@ let get_runtime_dir root_path = None)) | true -> Some root_path -let get_lib_bs path = Files.if_exists (path /+ "lib" /+ "bs") +(* A package's compiled files, flat in lib/rescript. *) +let get_artifact_dir path = Files.if_exists (path /+ "lib" /+ "rescript") +(* The runtime's compiled files. Its sources are at the root of the runtime + package, see [get_runtime_dir]. *) let get_stdlib base = match get_runtime_dir base with | None -> None - | Some runtime_dir -> Some (runtime_dir /+ "lib" /+ "ocaml") + | Some runtime_dir -> Some (runtime_dir /+ "lib" /+ "rescript") diff --git a/analysis/src/cache.ml b/analysis/src/cache.ml index a70f46c5029..9ea1dbd123e 100644 --- a/analysis/src/cache.ml +++ b/analysis/src/cache.ml @@ -23,8 +23,8 @@ let read_cache filename = let delete_cache filename = try Sys.remove filename with _ -> () -let target_file_from_lib_bs lib_bs = - Filename.concat lib_bs ".project-files-cache" +let target_file_from_artifact_dir artifact_dir = + Filename.concat artifact_dir ".project-files-cache" let cache_project (package : package) = let cached = @@ -34,9 +34,9 @@ let cache_project (package : package) = paths_for_module = package.paths_for_module; } in - match Build_system.get_lib_bs package.root_path with + match Build_system.get_artifact_dir package.root_path with | None -> print_endline "\"ERR\"" - | Some lib_bs -> - let target_file = target_file_from_lib_bs lib_bs in + | Some artifact_dir -> + let target_file = target_file_from_artifact_dir artifact_dir in write_cache target_file cached; print_endline "\"OK\"" diff --git a/analysis/src/cli.ml b/analysis/src/cli.ml index 82147931c90..3e6613ee88f 100644 --- a/analysis/src/cli.ml +++ b/analysis/src/cli.ml @@ -322,7 +322,7 @@ let test ~state ~path = let ( ++ ) = concat in let name = chop_extension (basename path) ^ ".cmi" in let dir = dirname path in - dir ++ parent_dir_name ++ "lib" ++ "bs" ++ "src" ++ name + dir ++ parent_dir_name ++ "lib" ++ "rescript" ++ name in create_interface ~path ~cmi_file | "ref" -> diff --git a/analysis/src/cmt.ml b/analysis/src/cmt.ml index e2936c3707a..5a0a97d6bb9 100644 --- a/analysis/src/cmt.ml +++ b/analysis/src/cmt.ml @@ -12,7 +12,7 @@ let full_for_incremental_cmt ~package ~module_name ~uri = if !Cfg.in_incremental_typechecking_mode then let path = Uri.to_path uri in let incremental_cmt_path = - package.root_path ^ "/lib/bs/___incremental" ^ "/" ^ module_name + package.root_path ^ "/lib/rescript/incremental" ^ "/" ^ module_name ^ match Files.classify_source_file path with | Resi -> ".cmti" diff --git a/analysis/src/find_files.ml b/analysis/src/find_files.ml index ee5e247f16e..07eeb282ff9 100644 --- a/analysis/src/find_files.ml +++ b/analysis/src/find_files.ml @@ -131,20 +131,27 @@ let get_public config = |> List.filter_map Yojson_helpers.string_opt |> String_set.of_list)) -let collect_files directory = - let all_files = Files.read_directory directory in +(* Pairs the compiled files in [compiled_directory] with the sources of the same + name in [source_directory], as the runtime ships them. *) +let collect_files ~compiled_directory ~source_directory = let compileds = - all_files |> List.filter is_compiled_file |> filter_duplicates + Files.read_directory compiled_directory + |> List.filter is_compiled_file + |> filter_duplicates + in + let sources = + Files.read_directory source_directory + |> List.filter is_source_file |> filter_duplicates in - let sources = all_files |> List.filter is_source_file |> filter_duplicates in compileds |> Utils.filter_map (fun path -> let mod_name = get_name path in - let cmt = directory /+ path in + let cmt = compiled_directory /+ path in let res_opt = Utils.find (fun name -> - if get_name name = mod_name then Some (directory /+ name) else None) + if get_name name = mod_name then Some (source_directory /+ name) + else None) sources in match res_opt with @@ -155,7 +162,7 @@ let collect_files directory = .sourcedirs.json when available. If a package is not listed there, analysis falls back to walking up node_modules from the project root. *) let read_sourcedirs_package_roots base = - let source_dirs_file = base /+ "lib" /+ "bs" /+ ".sourcedirs.json" in + let source_dirs_file = base /+ "lib" /+ "rescript" /+ ".sourcedirs.json" in let read_package_entry = function | `List [`String name; `String path] -> let path = if Filename.is_relative path then base /+ path else path in @@ -180,7 +187,8 @@ let find_package_root ~base ~sourcedirs_package_roots name = | _ -> Module_resolution.resolve_node_module_path ~start_path:base name (* returns a list of (absolute path to cmt(i), relative path from base to source file) *) -let find_project_files ~public ~namespace ~path ~source_directories ~lib_bs = +let find_project_files ~public ~namespace ~path ~source_directories + ~artifact_dir = let dirs = source_directories |> List.map (Filename.concat path) |> String_set.of_list in @@ -210,11 +218,12 @@ let find_project_files ~public ~namespace ~path ~source_directories ~lib_bs = let module_name = get_name file in let resi = Hashtbl.find_opt interfaces module_name in Hashtbl.remove interfaces module_name; - let base = compiled_base_name ~namespace (Files.relpath path file) in + (* Compiled files are flat in the artifact directory. *) + let base = compiled_base_name ~namespace (Filename.basename file) in match resi with | Some resi -> - let cmti = (lib_bs /+ base) ^ ".cmti" in - let cmt = (lib_bs /+ base) ^ ".cmt" in + let cmti = (artifact_dir /+ base) ^ ".cmti" in + let cmt = (artifact_dir /+ base) ^ ".cmt" in if Files.exists cmti then if Files.exists cmt then (* Log.log("Intf and impl " ++ cmti ++ " " ++ cmt) *) @@ -224,13 +233,14 @@ let find_project_files ~public ~namespace ~path ~source_directories ~lib_bs = else None else ( (* Log.log("Just intf " ++ cmti) *) - Log.log ("Bad source file (no cmt/cmti/cmi) " ^ (lib_bs /+ base)); + Log.log + ("Bad source file (no cmt/cmti/cmi) " ^ (artifact_dir /+ base)); None) | None -> - let cmt = (lib_bs /+ base) ^ ".cmt" in + let cmt = (artifact_dir /+ base) ^ ".cmt" in if Files.exists cmt then Some (module_name, Impl {cmt; res = file}) else ( - Log.log ("Bad source file (no cmt/cmi) " ^ (lib_bs /+ base)); + Log.log ("Bad source file (no cmt/cmi) " ^ (artifact_dir /+ base)); None)) else None) in @@ -253,7 +263,7 @@ let find_project_files ~public ~namespace ~path ~source_directories ~lib_bs = | None -> result | Some namespace -> let module_name = name_space_to_name namespace in - let cmt = (lib_bs /+ namespace) ^ ".cmt" in + let cmt = (artifact_dir /+ namespace) ^ ".cmt" in Log.log ("adding namespace " ^ namespace ^ " : " ^ module_name ^ " : " ^ cmt); (module_name, Namespace {cmt}) :: result @@ -303,20 +313,13 @@ let find_dependency_files base config = get_source_directories ~include_dev:false ~base_dir:path inner in - match Build_system.get_lib_bs path with + match Build_system.get_artifact_dir path with | None -> None - | Some lib_bs -> - let compiled_directories = - source_directories |> List.map (Filename.concat lib_bs) - in - let compiled_directories = - match namespace with - | None -> compiled_directories - | Some _ -> lib_bs :: compiled_directories - in + | Some artifact_dir -> + let compiled_directories = [artifact_dir] in let project_files = find_project_files ~public:(get_public inner) ~namespace - ~path ~source_directories ~lib_bs + ~path ~source_directories ~artifact_dir in Some (compiled_directories, project_files)) | None -> None @@ -334,12 +337,16 @@ let find_dependency_files base config = Log.log ("Skipping nonexistent dependency: " ^ name); ([], [])) in - match Build_system.get_stdlib base with - | None -> None - | Some stdlib_directory -> + match (Build_system.get_stdlib base, Build_system.get_runtime_dir base) with + | None, _ | _, None -> None + | Some stdlib_directory, Some runtime_dir -> let compiled_directories, project_files = let files, directories = List.split dep_files in (List.concat files, List.concat directories) in - let all_files = project_files @ collect_files stdlib_directory in + let all_files = + project_files + @ collect_files ~compiled_directory:stdlib_directory + ~source_directory:runtime_dir + in Some (compiled_directories, all_files) diff --git a/analysis/src/packages.ml b/analysis/src/packages.ml index fe58bcb263f..35fe083b4db 100644 --- a/analysis/src/packages.ml +++ b/analysis/src/packages.ml @@ -37,10 +37,10 @@ let new_bs_package ~root_path = let rescript_json = Filename.concat root_path "rescript.json" in let parse_raw raw = - let lib_bs = + let artifact_dir = match !Cfg.is_doc_gen_from_compiler with | true -> Build_system.get_stdlib root_path - | false -> Build_system.get_lib_bs root_path + | false -> Build_system.get_artifact_dir root_path in match Yojson_helpers.from_string_opt raw with | Some config -> ( @@ -82,10 +82,12 @@ let new_bs_package ~root_path = | _ -> Misc.String_map.empty) | None -> Misc.String_map.empty in - match lib_bs with + match artifact_dir with | None -> None - | Some lib_bs -> - let cached = Cache.read_cache (Cache.target_file_from_lib_bs lib_bs) in + | Some artifact_dir -> + let cached = + Cache.read_cache (Cache.target_file_from_artifact_dir artifact_dir) + in let project_files, dependencies_files, paths_for_module = match cached with | Some cached -> @@ -106,7 +108,7 @@ let new_bs_package ~root_path = let project_files_and_paths = Find_files.find_project_files ~public:(Find_files.get_public config) - ~namespace ~path:root_path ~source_directories ~lib_bs + ~namespace ~path:root_path ~source_directories ~artifact_dir in let paths_for_module = make_paths_for_module ~project_files_and_paths @@ -125,7 +127,7 @@ let new_bs_package ~root_path = match namespace with | None -> [] | Some namespace -> - let cmt = Filename.concat lib_bs namespace ^ ".cmt" in + let cmt = Filename.concat artifact_dir namespace ^ ".cmt" in Hashtbl.replace paths_for_module namespace (Namespace {cmt}); let path = [Find_files.name_space_to_name namespace] in [path] diff --git a/compiler/gentype/dune b/compiler/gentype/dune index 45396d8f7fd..1ac787d54d8 100644 --- a/compiler/gentype/dune +++ b/compiler/gentype/dune @@ -3,4 +3,4 @@ (wrapped false) (instrumentation (backend bisect_ppx)) - (libraries ml)) + (libraries depends ml)) diff --git a/compiler/gentype/emit_js.ml b/compiler/gentype/emit_js.ml index 2d047a5e671..e2fdb007a24 100644 --- a/compiler/gentype/emit_js.ml +++ b/compiler/gentype/emit_js.ml @@ -435,9 +435,7 @@ let rec read_cmt_files_recursively ~config ~env | exception Not_found -> env in let cmt_file = - import_path - |> Import_path.to_cmt ~config ~output_file_relative - |> Paths.get_cmt_file + import_path |> Import_path.to_cmt ~config |> Paths.get_cmt_file in match as_type_name with | Some as_type when cmt_file <> "" -> ( diff --git a/compiler/gentype/import_path.ml b/compiler/gentype/import_path.ml index 31beb79a084..00f75f53a07 100644 --- a/compiler/gentype/import_path.ml +++ b/compiler/gentype/import_path.ml @@ -17,15 +17,27 @@ let chop_extension_safe (dir, s) = let dump (dir, s) = Node_filename.concat dir s -let to_cmt ~(config : Config.t) ~output_file_relative (dir, s) = - let open Filename in - concat - (output_file_relative |> dirname) - ((dir, s) |> chop_extension_safe |> dump) - ^ (match config.namespace with - | None -> "" - | Some name -> "-" ^ name) - ^ ".cmt" +(* The compiled files of a package are flat in its artifact directory, the + compiler's working directory, so a module of the same package is found by + its file name there. Such a module's import path is relative, or, from an + output file at the project root, starts with one of its source + directories. A module of another package has no .cmt there. *) +let to_cmt ~(config : Config.t) (dir, s) = + let path = (dir, s) |> chop_extension_safe |> dump in + let is_local = + String.starts_with ~prefix:"./" path + || String.starts_with ~prefix:"../" path + || config.sources + |> List.exists (fun source -> + String.starts_with ~prefix:(source ^ "/") path) + in + if not is_local then "" + else + Filename.basename path + ^ (match config.namespace with + | None -> "" + | Some name -> "-" ^ name) + ^ ".cmt" (* Import paths are emitted inside single-quoted JavaScript/TypeScript string literals and also repeated in line comments. The AST stores their semantic diff --git a/compiler/gentype/import_path.mli b/compiler/gentype/import_path.mli index ff399e0314d..fefebfe3174 100644 --- a/compiler/gentype/import_path.mli +++ b/compiler/gentype/import_path.mli @@ -9,4 +9,7 @@ val dump : t -> string val emit : t -> string val from_module : dir:string -> import_extension:string -> Module_name.t -> t val from_string_unsafe : string -> t -val to_cmt : config:Config.t -> output_file_relative:string -> t -> string + +val to_cmt : config:Config.t -> t -> string +(** The .cmt of an imported module of the same package, relative to the + compiler's working directory, or "" for a module of another package. *) diff --git a/compiler/gentype/module_resolver.ml b/compiler/gentype/module_resolver.ml index 940fca43bef..a8ea31713ea 100644 --- a/compiler/gentype/module_resolver.ml +++ b/compiler/gentype/module_resolver.ml @@ -3,21 +3,107 @@ module Module_name_map = Config.Module_name_map let ( +++ ) = Filename.concat -(** Read all the dirs from a library in node_modules *) -let read_bs_dependencies_dirs ~root = - let dirs = ref [] in - let rec find_sub_dirs dir = - let abs_dir = - match dir = "" with - | true -> root - | false -> root +++ dir +(** The source path in the header of an AST file, read from its first bytes + (a header is a few hundred bytes), or [None] when the file is not an AST. *) +let ast_source path = + match open_in_bin path with + | exception Sys_error _ -> None + | channel -> + Fun.protect + ~finally:(fun () -> close_in_noerr channel) + (fun () -> + let read length = + let contents = really_input_string channel length in + Binary_ast.read_header contents + |> Option.map (Binary_ast.header_source contents) + in + let length = in_channel_length channel in + match read (min length 4096) with + | Some source -> Some source + | None when length > 4096 -> + seek_in channel 0; + read length + | None -> None) + +(** The directories of a dependency's sources, relative to its root, by the + name of their ASTs ([X] for [X.ast]): each AST records its source. *) +let read_source_dirs ~root ~artifact_dir names = + let prefix = root ^ Filename.dir_sep in + let source_dirs = Hashtbl.create 64 in + names + |> Array.iter (fun name -> + if Filename.check_suffix name ".ast" then + match ast_source (artifact_dir +++ name) with + | Some source when String.starts_with ~prefix source -> + let relative = + String.sub source (String.length prefix) + (String.length source - String.length prefix) + in + let dir = Filename.dirname relative in + Hashtbl.replace source_dirs + (Filename.chop_suffix name ".ast") + (if dir = Filename.current_dir_name then "" else dir) + | Some _ | None -> ()); + source_dirs + +(* Every gentype compile of a build resolves the same dependencies, and their + ASTs, unlike their compiled files, are complete once the build parsed. So + the AST headers are read once per build (a generation of the build file + store). *) +let source_dirs_cache = Hashtbl.create 8 +let source_dirs_mutex = Mutex.create () + +let source_dirs ~root ~artifact_dir names = + if not (Build_file_store.enabled ()) then + read_source_dirs ~root ~artifact_dir names + else + let generation = Build_file_store.generation () in + let locked f = + Mutex.lock source_dirs_mutex; + Fun.protect ~finally:(fun () -> Mutex.unlock source_dirs_mutex) f in - if Sys.file_exists abs_dir && Sys.is_directory abs_dir then ( - dirs := dir :: !dirs; - abs_dir |> Sys.readdir |> Array.iter (fun d -> find_sub_dirs (dir +++ d))) - in - find_sub_dirs ""; - !dirs + match locked (fun () -> Hashtbl.find_opt source_dirs_cache root) with + | Some (cached_generation, source_dirs) when cached_generation = generation + -> + source_dirs + | Some _ | None -> + let source_dirs = read_source_dirs ~root ~artifact_dir names in + locked (fun () -> + Hashtbl.replace source_dirs_cache root (generation, source_dirs)); + source_dirs + +(** The directories of a dependency's modules, relative to its root, by the + name of their compiled files. Its artifacts are flat in [lib/rescript], + so a module's [X.cmt] or [X-Ns.cmt] lies in the directory of the source + that [X.ast] names. *) +let dependency_module_dirs ~root = + let artifact_dir = ["lib"; "rescript"] |> List.fold_left ( +++ ) root in + if not (Sys.file_exists artifact_dir && Sys.is_directory artifact_dir) then [] + else + let names = Sys.readdir artifact_dir in + let source_dirs = source_dirs ~root ~artifact_dir names in + (* A namespaced module's compiled files append "-" and the namespace, + which has no "-" of its own, to the source file name. The namespace + itself has a map instead of a source, and belongs to the package root. *) + let source_dir compiled = + match Hashtbl.find_opt source_dirs compiled with + | Some dir -> Some dir + | None when Array.mem (compiled ^ ".mlmap") names -> Some "" + | None -> ( + match String.rindex_opt compiled '-' with + | Some index -> + Hashtbl.find_opt source_dirs (String.sub compiled 0 index) + | None -> None) + in + names |> Array.to_list + |> List.filter_map (fun name -> + if + Filename.check_suffix name ".cmt" + || Filename.check_suffix name ".cmti" + then + source_dir (Filename.remove_extension name) + |> Option.map (fun dir -> (name, dir)) + else None) (** Build a map of source filenames (with the given extensions) back to the directory where they belong. Source directories and dependency install @@ -54,17 +140,13 @@ let sourcedirs_to_map ~(config : Config.t) ~extensions ~exclude_file = |> List.iter (fun package_name -> match Hashtbl.find config.dep_paths package_name with | path -> - let root = ["lib"; "bs"] |> List.fold_left ( +++ ) path in - let filter file_name = - [".cmt"; ".cmti"] - |> List.exists (fun ext -> Filename.check_suffix file_name ext) - in - read_bs_dependencies_dirs ~root - |> List.iter (fun dir -> - let dir_on_disk = root +++ dir in - let dir_emitted = package_name +++ dir in - add_dir ~dir_emitted ~dir_on_disk ~filter - ~map:bs_dependencies_file_map) + dependency_module_dirs ~root:path + |> List.iter (fun (fname, dir) -> + bs_dependencies_file_map := + !bs_dependencies_file_map + |> Module_name_map.add + (fname |> chop_extensions |> Module_name.from_string_unsafe) + (package_name +++ dir)) | exception Not_found -> ()); (!file_map, !bs_dependencies_file_map) diff --git a/compiler/gentype/paths.ml b/compiler/gentype/paths.ml index 4c9bd15c6d2..fc6c065bc5c 100644 --- a/compiler/gentype/paths.ml +++ b/compiler/gentype/paths.ml @@ -75,10 +75,15 @@ let get_cmt_file cmt = let path_cmti_lower_case = (Filename.chop_extension path_cmt_lower_case [@doesNotRaise]) ^ ".cmti" in - if Sys.file_exists path_cmti_lower_case then path_cmti_lower_case - else if Sys.file_exists path_cmti then path_cmti - else if Sys.file_exists path_cmt_lower_case then path_cmt_lower_case - else if Sys.file_exists path_cmt then path_cmt + (* The compiler's spelling first: on a case-insensitive file system + the lowercase one exists too, and the build file store, which holds + the typed tree of the module being compiled, knows only the + compiler's spelling. *) + let exists = Build_file_store.exists in + if exists path_cmti then path_cmti + else if exists path_cmti_lower_case then path_cmti_lower_case + else if exists path_cmt then path_cmt + else if exists path_cmt_lower_case then path_cmt_lower_case else "" else "" in diff --git a/tests/analysis_tests/tests-namespaced-references/Makefile b/tests/analysis_tests/tests-namespaced-references/Makefile index dfc867973c7..cff580e839f 100644 --- a/tests/analysis_tests/tests-namespaced-references/Makefile +++ b/tests/analysis_tests/tests-namespaced-references/Makefile @@ -4,10 +4,10 @@ build: yarn build # Simulate editor-written incremental CMTs - mkdir -p lib/bs/___incremental - cp lib/bs/src/MyModule1-MyNamespace.cmt lib/bs/___incremental/MyModule1-MyNamespace.cmt - cp lib/bs/src/MyModule2-MyNamespace.cmt lib/bs/___incremental/MyModule2-MyNamespace.cmt - cp lib/bs/MyNamespace.cmt lib/bs/___incremental/MyNamespace.cmt + mkdir -p lib/rescript/incremental + cp lib/rescript/MyModule1-MyNamespace.cmt lib/rescript/incremental/MyModule1-MyNamespace.cmt + cp lib/rescript/MyModule2-MyNamespace.cmt lib/rescript/incremental/MyModule2-MyNamespace.cmt + cp lib/rescript/MyNamespace.cmt lib/rescript/incremental/MyNamespace.cmt test: build bash ./test.sh diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt b/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt index 19aa5046672..d523b404733 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt +++ b/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt @@ -8,6 +8,7 @@ addDeclaration_ VariantCase R2 AutoAnnotate.res:14:2 path:+AutoAnnotate.annotatedVariant addDeclaration_ VariantCase R4 AutoAnnotate.res:15:2 path:+AutoAnnotate.annotatedVariant Scanning BootloaderResource.cmt Source:BootloaderResource.res + Implementation 0 Scanning BucklescriptAnnotations.cmt Source:BucklescriptAnnotations.res addDeclaration_ Value +bar BucklescriptAnnotations.res:22:4 path:+BucklescriptAnnotations addDeclaration_ Value +f BucklescriptAnnotations.res:23:6 path:+BucklescriptAnnotations @@ -2007,7 +2008,6 @@ add_value_reference VariantsWithPayload.res:93:4 --> VariantsWithPayload.res:93:23 addDeclaration_ VariantCase R VariantsWithPayload.res:96:22 path:+VariantsWithPayload.variant1Object add_value_reference VariantsWithPayload.res:99:4 --> VariantsWithPayload.res:99:26 - Implementation 0 Warning Dead Module AutoAnnotate.res:0:1 From 5049bbca71f53daea9997debbab8125f1613f7fb Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Fri, 6 Nov 2026 13:36:13 +0000 Subject: [PATCH 3/3] Ship the runtime's lib/rescript and sources, and update CI, build tests and docs Why: The runtime package shipped lib/ocaml with copies of its sources; it now ships lib/rescript and its own sources at the package root, which analysis reads (#9151). The release artifact, its CI upload and the playground's cmij extraction take lib/rescript, its build state stays out of the package, and the ignore files name lib/rescript. Build tests read the in-source outputs that the JS mirror used to copy, and look for the debug IR, the belt interfaces and post-build paths under lib/rescript; the installation test looks for the watch lock there. The changelog fragment lists the new paths for tools that read the old ones and says that lib/rescript belongs in .gitignore. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Kbf3gGBR9g3DD93vrWbYzU Signed-off-by: Christoph Knittel --- .github/workflows/ci.yml | 13 +- .github/workflows/moveArtifacts.sh | 2 +- .github/workflows/publish.yml | 2 +- .gitignore | 2 +- CONTRIBUTING.md | 2 +- biome.json | 2 +- changes/lib-rescript.breaking.md | 1 + packages/@rescript/belt/.gitignore | 3 +- packages/@rescript/runtime/.gitignore | 3 +- packages/@rescript/runtime/lib/.npmignore | 10 +- packages/@rescript/runtime/package.json | 4 +- packages/artifacts.json | 1084 ++++++++--------- .../playground/scripts/generate_cmijs.mjs | 10 +- tests/build_tests/debug_ir/input.js | 3 +- .../post-build-out-of-source/input.js | 9 +- tests/build_tests/post-build/input.js | 8 +- tests/build_tests/source_map/input.js | 16 +- tests/build_tests/super_errors/input.js | 2 +- tests/build_tests/unicode/input.js | 4 +- .../installation_test/packaged-cli-smoke.mjs | 2 +- tests/syntax_tests/res_test.ml | 2 - 21 files changed, 593 insertions(+), 591 deletions(-) create mode 100644 changes/lib-rescript.breaking.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f0dec57a44..41273627372 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -326,15 +326,16 @@ jobs: name: binaries-${{ matrix.node-target }} path: packages/@rescript/${{ matrix.node-target }}/bin - - name: "Upload artifacts: lib/ocaml" + - name: "Upload artifacts: lib/rescript" if: matrix.upload_libs uses: actions/upload-artifact@v7 with: - name: lib-ocaml + name: lib-rescript path: | - packages/@rescript/runtime/lib/ocaml - !packages/@rescript/runtime/lib/ocaml/*.ast - !packages/@rescript/runtime/lib/ocaml/*.iast + packages/@rescript/runtime/lib/rescript + !packages/@rescript/runtime/lib/rescript/*.ast + !packages/@rescript/runtime/lib/rescript/*.iast + !packages/@rescript/runtime/lib/rescript/compiler-info.json - name: Select API docs website branch id: api-docs-plan @@ -423,7 +424,7 @@ jobs: - name: Download artifacts uses: actions/download-artifact@v8 with: - pattern: "@(binaries-*|lib-ocaml)" + pattern: "@(binaries-*|lib-rescript)" - name: Move artifacts into packages run: .github/workflows/moveArtifacts.sh diff --git a/.github/workflows/moveArtifacts.sh b/.github/workflows/moveArtifacts.sh index 978ee6cd00e..11dd9185fc8 100755 --- a/.github/workflows/moveArtifacts.sh +++ b/.github/workflows/moveArtifacts.sh @@ -26,7 +26,7 @@ check_statically_linked() { } # rescript -mv lib-ocaml packages/@rescript/runtime/lib/ocaml +mv lib-rescript packages/@rescript/runtime/lib/rescript # @rescript/{target} chmod +x binaries-*/*.exe diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8bf21beadc6..87cfabfe0e6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -112,7 +112,7 @@ jobs: - name: Download artifacts uses: actions/download-artifact@v8 with: - pattern: "@(binaries-*|lib-ocaml)" + pattern: "@(binaries-*|lib-rescript)" - name: Move artifacts into packages run: .github/workflows/moveArtifacts.sh diff --git a/.gitignore b/.gitignore index 89292ae6159..d296ba54b88 100644 --- a/.gitignore +++ b/.gitignore @@ -49,7 +49,7 @@ node_modules _coverage/ bisect*.coverage -lib/ocaml +lib/rescript tests/build_tests/*/lib/ #ignore temporary directory *.goog.js diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1e9a6826df9..3d118f9f824 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -262,7 +262,7 @@ To view the typed tree of the file run: ### Project ```sh -make artifacts # Build compiler and standard library and populate lib/ocaml +make artifacts # Build compiler and standard library and populate lib/rescript npm link cd myProject npm install diff --git a/biome.json b/biome.json index 48f90df1cf2..5f7f0c8416a 100644 --- a/biome.json +++ b/biome.json @@ -67,7 +67,7 @@ "!**/rewatch-ocaml", "!**/lib/es6", "!**/lib/js", - "!**/lib/bs", + "!**/lib/rescript", "!**/playground", "!**/*.bs.js", "!**/*.res.js", diff --git a/changes/lib-rescript.breaking.md b/changes/lib-rescript.breaking.md new file mode 100644 index 00000000000..521b5606eab --- /dev/null +++ b/changes/lib-rescript.breaking.md @@ -0,0 +1 @@ +- Build output moves from `lib/bs` and `lib/ocaml` into one flat `lib/rescript` directory per package, without copies of the sources or the generated JavaScript; the first build removes the old directories, and `lib/rescript` belongs in `.gitignore`. Tools that read `lib/bs/.compiler.log`, `lib/bs/compiler-info.json` or `lib/ocaml` now find these files in `lib/rescript`, and the editor's scratch directory is `lib/rescript/incremental`. The empty `lib/bs/build.ninja` marker is gone; `lib/rescript/.sourcedirs.json` is rewritten when the project graph changes. `@rescript/runtime` ships its sources at the package root. diff --git a/packages/@rescript/belt/.gitignore b/packages/@rescript/belt/.gitignore index 97db98ea625..4f7a57b4906 100644 --- a/packages/@rescript/belt/.gitignore +++ b/packages/@rescript/belt/.gitignore @@ -1,5 +1,4 @@ -lib/bs -lib/ocaml +lib/rescript *.lock .buildstamp bs/ diff --git a/packages/@rescript/runtime/.gitignore b/packages/@rescript/runtime/.gitignore index 0aeb240499b..7a75320a84d 100644 --- a/packages/@rescript/runtime/.gitignore +++ b/packages/@rescript/runtime/.gitignore @@ -1,4 +1,3 @@ -lib/bs -lib/ocaml +lib/rescript *.lock .buildstamp diff --git a/packages/@rescript/runtime/lib/.npmignore b/packages/@rescript/runtime/lib/.npmignore index 9fb6c6decf3..73f52a17c2f 100644 --- a/packages/@rescript/runtime/lib/.npmignore +++ b/packages/@rescript/runtime/lib/.npmignore @@ -1,5 +1,11 @@ -bs/ *.ast *.iast -rescript.lock +*.lock .compiler.log +.sourcedirs.json +.project-files-cache +compiler-info.json +rescript/incremental/ +*.tmp +*.takeover +*.debug-ir diff --git a/packages/@rescript/runtime/package.json b/packages/@rescript/runtime/package.json index 543795763e9..173a2dd6c6b 100644 --- a/packages/@rescript/runtime/package.json +++ b/packages/@rescript/runtime/package.json @@ -33,7 +33,9 @@ "provenance": true }, "files": [ - "lib" + "lib", + "*.res", + "*.resi" ], "exports": { "./lib/es6/*": "./lib/es6/*", diff --git a/packages/artifacts.json b/packages/artifacts.json index f93c2ea104f..5f6835cd08d 100644 --- a/packages/artifacts.json +++ b/packages/artifacts.json @@ -21,6 +21,164 @@ "package.json" ], "@rescript/runtime": [ + "Dom.res", + "Dom_storage.res", + "Dom_storage2.res", + "Jsx.res", + "JsxDOM.res", + "JsxDOMStyle.res", + "JsxEvent.res", + "Obj.res", + "Pervasives.res", + "Primitive_array.res", + "Primitive_array_extern.res", + "Primitive_bigint.res", + "Primitive_bool.res", + "Primitive_dict.res", + "Primitive_exceptions.res", + "Primitive_exceptions.resi", + "Primitive_float.res", + "Primitive_float_extern.res", + "Primitive_hash.res", + "Primitive_hash.resi", + "Primitive_int.res", + "Primitive_int_extern.res", + "Primitive_js_extern.res", + "Primitive_list.res", + "Primitive_list.resi", + "Primitive_module.res", + "Primitive_module.resi", + "Primitive_object.res", + "Primitive_object.resi", + "Primitive_object_extern.res", + "Primitive_option.res", + "Primitive_option.resi", + "Primitive_promise.res", + "Primitive_string.res", + "Primitive_string_extern.res", + "RescriptTools.res", + "RescriptTools_Docgen.res", + "RescriptTools_Docgen.resi", + "RescriptTools_ExtractCodeBlocks.res", + "Stdlib.res", + "Stdlib_Array.res", + "Stdlib_Array.resi", + "Stdlib_ArrayBuffer.res", + "Stdlib_ArrayBuffer.resi", + "Stdlib_AsyncGenerator.res", + "Stdlib_AsyncGenerator.resi", + "Stdlib_AsyncIterable.res", + "Stdlib_AsyncIterable.resi", + "Stdlib_AsyncIterableIterator.res", + "Stdlib_AsyncIterableIterator.resi", + "Stdlib_AsyncIterator.res", + "Stdlib_AsyncIterator.resi", + "Stdlib_BigInt.res", + "Stdlib_BigInt.resi", + "Stdlib_BigInt64Array.res", + "Stdlib_BigUint64Array.res", + "Stdlib_Blob.res", + "Stdlib_Bool.res", + "Stdlib_Bool.resi", + "Stdlib_Console.res", + "Stdlib_Console.resi", + "Stdlib_DataView.res", + "Stdlib_DataView.resi", + "Stdlib_Date.res", + "Stdlib_Date.resi", + "Stdlib_Dict.res", + "Stdlib_Dict.resi", + "Stdlib_File.res", + "Stdlib_Float.res", + "Stdlib_Float.resi", + "Stdlib_Float32Array.res", + "Stdlib_Float64Array.res", + "Stdlib_Generator.res", + "Stdlib_Generator.resi", + "Stdlib_Global.res", + "Stdlib_Global.resi", + "Stdlib_Int.res", + "Stdlib_Int.resi", + "Stdlib_Int16Array.res", + "Stdlib_Int32Array.res", + "Stdlib_Int8Array.res", + "Stdlib_Intl.res", + "Stdlib_Intl_Collator.res", + "Stdlib_Intl_Common.res", + "Stdlib_Intl_DateTimeFormat.res", + "Stdlib_Intl_ListFormat.res", + "Stdlib_Intl_Locale.res", + "Stdlib_Intl_NumberFormat.res", + "Stdlib_Intl_NumberFormat_Grouping.res", + "Stdlib_Intl_PluralRules.res", + "Stdlib_Intl_RelativeTimeFormat.res", + "Stdlib_Intl_Segmenter.res", + "Stdlib_Intl_Segments.res", + "Stdlib_Iterable.res", + "Stdlib_Iterable.resi", + "Stdlib_IterableIterator.res", + "Stdlib_IterableIterator.resi", + "Stdlib_Iterator.res", + "Stdlib_Iterator.resi", + "Stdlib_IteratorObject.res", + "Stdlib_IteratorObject.resi", + "Stdlib_JSON.res", + "Stdlib_JSON.resi", + "Stdlib_JsError.res", + "Stdlib_JsError.resi", + "Stdlib_JsExn.res", + "Stdlib_JsExn.resi", + "Stdlib_Lazy.res", + "Stdlib_Lazy.resi", + "Stdlib_List.res", + "Stdlib_List.resi", + "Stdlib_Map.res", + "Stdlib_Map.resi", + "Stdlib_Math.res", + "Stdlib_Math.resi", + "Stdlib_Null.res", + "Stdlib_Null.resi", + "Stdlib_Nullable.res", + "Stdlib_Nullable.resi", + "Stdlib_Object.res", + "Stdlib_Option.res", + "Stdlib_Option.resi", + "Stdlib_Ordering.res", + "Stdlib_Pair.res", + "Stdlib_Promise.res", + "Stdlib_Promise.resi", + "Stdlib_RegExp.res", + "Stdlib_RegExp.resi", + "Stdlib_Result.res", + "Stdlib_Result.resi", + "Stdlib_Set.res", + "Stdlib_Set.resi", + "Stdlib_String.res", + "Stdlib_String.resi", + "Stdlib_Symbol.res", + "Stdlib_Symbol.resi", + "Stdlib_TaggedTemplate.res", + "Stdlib_TaggedTemplate.resi", + "Stdlib_Temporal.res", + "Stdlib_Temporal_Common.res", + "Stdlib_Temporal_Duration.res", + "Stdlib_Temporal_Instant.res", + "Stdlib_Temporal_Now.res", + "Stdlib_Temporal_PlainDate.res", + "Stdlib_Temporal_PlainDateTime.res", + "Stdlib_Temporal_PlainMonthDay.res", + "Stdlib_Temporal_PlainTime.res", + "Stdlib_Temporal_PlainYearMonth.res", + "Stdlib_Temporal_ZonedDateTime.res", + "Stdlib_Type.res", + "Stdlib_Type.resi", + "Stdlib_TypedArray.res", + "Stdlib_Uint16Array.res", + "Stdlib_Uint32Array.res", + "Stdlib_Uint8Array.res", + "Stdlib_Uint8ClampedArray.res", + "Stdlib_WeakMap.res", + "Stdlib_WeakSet.res", "lib/es6/Dom.mjs", "lib/es6/Dom_storage.mjs", "lib/es6/Dom_storage2.mjs", @@ -247,548 +405,390 @@ "lib/js/Stdlib_Uint8ClampedArray.cjs", "lib/js/Stdlib_WeakMap.cjs", "lib/js/Stdlib_WeakSet.cjs", - "lib/ocaml/Dom.cmi", - "lib/ocaml/Dom.cmj", - "lib/ocaml/Dom.cmt", - "lib/ocaml/Dom.res", - "lib/ocaml/Dom_storage.cmi", - "lib/ocaml/Dom_storage.cmj", - "lib/ocaml/Dom_storage.cmt", - "lib/ocaml/Dom_storage.res", - "lib/ocaml/Dom_storage2.cmi", - "lib/ocaml/Dom_storage2.cmj", - "lib/ocaml/Dom_storage2.cmt", - "lib/ocaml/Dom_storage2.res", - "lib/ocaml/Jsx.cmi", - "lib/ocaml/Jsx.cmj", - "lib/ocaml/Jsx.cmt", - "lib/ocaml/Jsx.res", - "lib/ocaml/JsxDOM.cmi", - "lib/ocaml/JsxDOM.cmj", - "lib/ocaml/JsxDOM.cmt", - "lib/ocaml/JsxDOM.res", - "lib/ocaml/JsxDOMStyle.cmi", - "lib/ocaml/JsxDOMStyle.cmj", - "lib/ocaml/JsxDOMStyle.cmt", - "lib/ocaml/JsxDOMStyle.res", - "lib/ocaml/JsxEvent.cmi", - "lib/ocaml/JsxEvent.cmj", - "lib/ocaml/JsxEvent.cmt", - "lib/ocaml/JsxEvent.res", - "lib/ocaml/Obj.cmi", - "lib/ocaml/Obj.cmj", - "lib/ocaml/Obj.cmt", - "lib/ocaml/Obj.res", - "lib/ocaml/Pervasives.cmi", - "lib/ocaml/Pervasives.cmj", - "lib/ocaml/Pervasives.cmt", - "lib/ocaml/Pervasives.res", - "lib/ocaml/Primitive_array.cmi", - "lib/ocaml/Primitive_array.cmj", - "lib/ocaml/Primitive_array.cmt", - "lib/ocaml/Primitive_array.res", - "lib/ocaml/Primitive_array_extern.cmi", - "lib/ocaml/Primitive_array_extern.cmj", - "lib/ocaml/Primitive_array_extern.cmt", - "lib/ocaml/Primitive_array_extern.res", - "lib/ocaml/Primitive_bigint.cmi", - "lib/ocaml/Primitive_bigint.cmj", - "lib/ocaml/Primitive_bigint.cmt", - "lib/ocaml/Primitive_bigint.res", - "lib/ocaml/Primitive_bool.cmi", - "lib/ocaml/Primitive_bool.cmj", - "lib/ocaml/Primitive_bool.cmt", - "lib/ocaml/Primitive_bool.res", - "lib/ocaml/Primitive_dict.cmi", - "lib/ocaml/Primitive_dict.cmj", - "lib/ocaml/Primitive_dict.cmt", - "lib/ocaml/Primitive_dict.res", - "lib/ocaml/Primitive_exceptions.cmi", - "lib/ocaml/Primitive_exceptions.cmj", - "lib/ocaml/Primitive_exceptions.cmt", - "lib/ocaml/Primitive_exceptions.cmti", - "lib/ocaml/Primitive_exceptions.res", - "lib/ocaml/Primitive_exceptions.resi", - "lib/ocaml/Primitive_float.cmi", - "lib/ocaml/Primitive_float.cmj", - "lib/ocaml/Primitive_float.cmt", - "lib/ocaml/Primitive_float.res", - "lib/ocaml/Primitive_float_extern.cmi", - "lib/ocaml/Primitive_float_extern.cmj", - "lib/ocaml/Primitive_float_extern.cmt", - "lib/ocaml/Primitive_float_extern.res", - "lib/ocaml/Primitive_hash.cmi", - "lib/ocaml/Primitive_hash.cmj", - "lib/ocaml/Primitive_hash.cmt", - "lib/ocaml/Primitive_hash.cmti", - "lib/ocaml/Primitive_hash.res", - "lib/ocaml/Primitive_hash.resi", - "lib/ocaml/Primitive_int.cmi", - "lib/ocaml/Primitive_int.cmj", - "lib/ocaml/Primitive_int.cmt", - "lib/ocaml/Primitive_int.res", - "lib/ocaml/Primitive_int_extern.cmi", - "lib/ocaml/Primitive_int_extern.cmj", - "lib/ocaml/Primitive_int_extern.cmt", - "lib/ocaml/Primitive_int_extern.res", - "lib/ocaml/Primitive_js_extern.cmi", - "lib/ocaml/Primitive_js_extern.cmj", - "lib/ocaml/Primitive_js_extern.cmt", - "lib/ocaml/Primitive_js_extern.res", - "lib/ocaml/Primitive_list.cmi", - "lib/ocaml/Primitive_list.cmj", - "lib/ocaml/Primitive_list.cmt", - "lib/ocaml/Primitive_list.cmti", - "lib/ocaml/Primitive_list.res", - "lib/ocaml/Primitive_list.resi", - "lib/ocaml/Primitive_module.cmi", - "lib/ocaml/Primitive_module.cmj", - "lib/ocaml/Primitive_module.cmt", - "lib/ocaml/Primitive_module.cmti", - "lib/ocaml/Primitive_module.res", - "lib/ocaml/Primitive_module.resi", - "lib/ocaml/Primitive_object.cmi", - "lib/ocaml/Primitive_object.cmj", - "lib/ocaml/Primitive_object.cmt", - "lib/ocaml/Primitive_object.cmti", - "lib/ocaml/Primitive_object.res", - "lib/ocaml/Primitive_object.resi", - "lib/ocaml/Primitive_object_extern.cmi", - "lib/ocaml/Primitive_object_extern.cmj", - "lib/ocaml/Primitive_object_extern.cmt", - "lib/ocaml/Primitive_object_extern.res", - "lib/ocaml/Primitive_option.cmi", - "lib/ocaml/Primitive_option.cmj", - "lib/ocaml/Primitive_option.cmt", - "lib/ocaml/Primitive_option.cmti", - "lib/ocaml/Primitive_option.res", - "lib/ocaml/Primitive_option.resi", - "lib/ocaml/Primitive_promise.cmi", - "lib/ocaml/Primitive_promise.cmj", - "lib/ocaml/Primitive_promise.cmt", - "lib/ocaml/Primitive_promise.res", - "lib/ocaml/Primitive_string.cmi", - "lib/ocaml/Primitive_string.cmj", - "lib/ocaml/Primitive_string.cmt", - "lib/ocaml/Primitive_string.res", - "lib/ocaml/Primitive_string_extern.cmi", - "lib/ocaml/Primitive_string_extern.cmj", - "lib/ocaml/Primitive_string_extern.cmt", - "lib/ocaml/Primitive_string_extern.res", - "lib/ocaml/RescriptTools.cmi", - "lib/ocaml/RescriptTools.cmj", - "lib/ocaml/RescriptTools.cmt", - "lib/ocaml/RescriptTools.res", - "lib/ocaml/RescriptTools_Docgen.cmi", - "lib/ocaml/RescriptTools_Docgen.cmj", - "lib/ocaml/RescriptTools_Docgen.cmt", - "lib/ocaml/RescriptTools_Docgen.cmti", - "lib/ocaml/RescriptTools_Docgen.res", - "lib/ocaml/RescriptTools_Docgen.resi", - "lib/ocaml/RescriptTools_ExtractCodeBlocks.cmi", - "lib/ocaml/RescriptTools_ExtractCodeBlocks.cmj", - "lib/ocaml/RescriptTools_ExtractCodeBlocks.cmt", - "lib/ocaml/RescriptTools_ExtractCodeBlocks.res", - "lib/ocaml/Stdlib.cmi", - "lib/ocaml/Stdlib.cmj", - "lib/ocaml/Stdlib.cmt", - "lib/ocaml/Stdlib.res", - "lib/ocaml/Stdlib_Array.cmi", - "lib/ocaml/Stdlib_Array.cmj", - "lib/ocaml/Stdlib_Array.cmt", - "lib/ocaml/Stdlib_Array.cmti", - "lib/ocaml/Stdlib_Array.res", - "lib/ocaml/Stdlib_Array.resi", - "lib/ocaml/Stdlib_ArrayBuffer.cmi", - "lib/ocaml/Stdlib_ArrayBuffer.cmj", - "lib/ocaml/Stdlib_ArrayBuffer.cmt", - "lib/ocaml/Stdlib_ArrayBuffer.cmti", - "lib/ocaml/Stdlib_ArrayBuffer.res", - "lib/ocaml/Stdlib_ArrayBuffer.resi", - "lib/ocaml/Stdlib_AsyncGenerator.cmi", - "lib/ocaml/Stdlib_AsyncGenerator.cmj", - "lib/ocaml/Stdlib_AsyncGenerator.cmt", - "lib/ocaml/Stdlib_AsyncGenerator.cmti", - "lib/ocaml/Stdlib_AsyncGenerator.res", - "lib/ocaml/Stdlib_AsyncGenerator.resi", - "lib/ocaml/Stdlib_AsyncIterable.cmi", - "lib/ocaml/Stdlib_AsyncIterable.cmj", - "lib/ocaml/Stdlib_AsyncIterable.cmt", - "lib/ocaml/Stdlib_AsyncIterable.cmti", - "lib/ocaml/Stdlib_AsyncIterable.res", - "lib/ocaml/Stdlib_AsyncIterable.resi", - "lib/ocaml/Stdlib_AsyncIterableIterator.cmi", - "lib/ocaml/Stdlib_AsyncIterableIterator.cmj", - "lib/ocaml/Stdlib_AsyncIterableIterator.cmt", - "lib/ocaml/Stdlib_AsyncIterableIterator.cmti", - "lib/ocaml/Stdlib_AsyncIterableIterator.res", - "lib/ocaml/Stdlib_AsyncIterableIterator.resi", - "lib/ocaml/Stdlib_AsyncIterator.cmi", - "lib/ocaml/Stdlib_AsyncIterator.cmj", - "lib/ocaml/Stdlib_AsyncIterator.cmt", - "lib/ocaml/Stdlib_AsyncIterator.cmti", - "lib/ocaml/Stdlib_AsyncIterator.res", - "lib/ocaml/Stdlib_AsyncIterator.resi", - "lib/ocaml/Stdlib_BigInt.cmi", - "lib/ocaml/Stdlib_BigInt.cmj", - "lib/ocaml/Stdlib_BigInt.cmt", - "lib/ocaml/Stdlib_BigInt.cmti", - "lib/ocaml/Stdlib_BigInt.res", - "lib/ocaml/Stdlib_BigInt.resi", - "lib/ocaml/Stdlib_BigInt64Array.cmi", - "lib/ocaml/Stdlib_BigInt64Array.cmj", - "lib/ocaml/Stdlib_BigInt64Array.cmt", - "lib/ocaml/Stdlib_BigInt64Array.res", - "lib/ocaml/Stdlib_BigUint64Array.cmi", - "lib/ocaml/Stdlib_BigUint64Array.cmj", - "lib/ocaml/Stdlib_BigUint64Array.cmt", - "lib/ocaml/Stdlib_BigUint64Array.res", - "lib/ocaml/Stdlib_Blob.cmi", - "lib/ocaml/Stdlib_Blob.cmj", - "lib/ocaml/Stdlib_Blob.cmt", - "lib/ocaml/Stdlib_Blob.res", - "lib/ocaml/Stdlib_Bool.cmi", - "lib/ocaml/Stdlib_Bool.cmj", - "lib/ocaml/Stdlib_Bool.cmt", - "lib/ocaml/Stdlib_Bool.cmti", - "lib/ocaml/Stdlib_Bool.res", - "lib/ocaml/Stdlib_Bool.resi", - "lib/ocaml/Stdlib_Console.cmi", - "lib/ocaml/Stdlib_Console.cmj", - "lib/ocaml/Stdlib_Console.cmt", - "lib/ocaml/Stdlib_Console.cmti", - "lib/ocaml/Stdlib_Console.res", - "lib/ocaml/Stdlib_Console.resi", - "lib/ocaml/Stdlib_DataView.cmi", - "lib/ocaml/Stdlib_DataView.cmj", - "lib/ocaml/Stdlib_DataView.cmt", - "lib/ocaml/Stdlib_DataView.cmti", - "lib/ocaml/Stdlib_DataView.res", - "lib/ocaml/Stdlib_DataView.resi", - "lib/ocaml/Stdlib_Date.cmi", - "lib/ocaml/Stdlib_Date.cmj", - "lib/ocaml/Stdlib_Date.cmt", - "lib/ocaml/Stdlib_Date.cmti", - "lib/ocaml/Stdlib_Date.res", - "lib/ocaml/Stdlib_Date.resi", - "lib/ocaml/Stdlib_Dict.cmi", - "lib/ocaml/Stdlib_Dict.cmj", - "lib/ocaml/Stdlib_Dict.cmt", - "lib/ocaml/Stdlib_Dict.cmti", - "lib/ocaml/Stdlib_Dict.res", - "lib/ocaml/Stdlib_Dict.resi", - "lib/ocaml/Stdlib_File.cmi", - "lib/ocaml/Stdlib_File.cmj", - "lib/ocaml/Stdlib_File.cmt", - "lib/ocaml/Stdlib_File.res", - "lib/ocaml/Stdlib_Float.cmi", - "lib/ocaml/Stdlib_Float.cmj", - "lib/ocaml/Stdlib_Float.cmt", - "lib/ocaml/Stdlib_Float.cmti", - "lib/ocaml/Stdlib_Float.res", - "lib/ocaml/Stdlib_Float.resi", - "lib/ocaml/Stdlib_Float32Array.cmi", - "lib/ocaml/Stdlib_Float32Array.cmj", - "lib/ocaml/Stdlib_Float32Array.cmt", - "lib/ocaml/Stdlib_Float32Array.res", - "lib/ocaml/Stdlib_Float64Array.cmi", - "lib/ocaml/Stdlib_Float64Array.cmj", - "lib/ocaml/Stdlib_Float64Array.cmt", - "lib/ocaml/Stdlib_Float64Array.res", - "lib/ocaml/Stdlib_Generator.cmi", - "lib/ocaml/Stdlib_Generator.cmj", - "lib/ocaml/Stdlib_Generator.cmt", - "lib/ocaml/Stdlib_Generator.cmti", - "lib/ocaml/Stdlib_Generator.res", - "lib/ocaml/Stdlib_Generator.resi", - "lib/ocaml/Stdlib_Global.cmi", - "lib/ocaml/Stdlib_Global.cmj", - "lib/ocaml/Stdlib_Global.cmt", - "lib/ocaml/Stdlib_Global.cmti", - "lib/ocaml/Stdlib_Global.res", - "lib/ocaml/Stdlib_Global.resi", - "lib/ocaml/Stdlib_Int.cmi", - "lib/ocaml/Stdlib_Int.cmj", - "lib/ocaml/Stdlib_Int.cmt", - "lib/ocaml/Stdlib_Int.cmti", - "lib/ocaml/Stdlib_Int.res", - "lib/ocaml/Stdlib_Int.resi", - "lib/ocaml/Stdlib_Int16Array.cmi", - "lib/ocaml/Stdlib_Int16Array.cmj", - "lib/ocaml/Stdlib_Int16Array.cmt", - "lib/ocaml/Stdlib_Int16Array.res", - "lib/ocaml/Stdlib_Int32Array.cmi", - "lib/ocaml/Stdlib_Int32Array.cmj", - "lib/ocaml/Stdlib_Int32Array.cmt", - "lib/ocaml/Stdlib_Int32Array.res", - "lib/ocaml/Stdlib_Int8Array.cmi", - "lib/ocaml/Stdlib_Int8Array.cmj", - "lib/ocaml/Stdlib_Int8Array.cmt", - "lib/ocaml/Stdlib_Int8Array.res", - "lib/ocaml/Stdlib_Intl.cmi", - "lib/ocaml/Stdlib_Intl.cmj", - "lib/ocaml/Stdlib_Intl.cmt", - "lib/ocaml/Stdlib_Intl.res", - "lib/ocaml/Stdlib_Intl_Collator.cmi", - "lib/ocaml/Stdlib_Intl_Collator.cmj", - "lib/ocaml/Stdlib_Intl_Collator.cmt", - "lib/ocaml/Stdlib_Intl_Collator.res", - "lib/ocaml/Stdlib_Intl_Common.cmi", - "lib/ocaml/Stdlib_Intl_Common.cmj", - "lib/ocaml/Stdlib_Intl_Common.cmt", - "lib/ocaml/Stdlib_Intl_Common.res", - "lib/ocaml/Stdlib_Intl_DateTimeFormat.cmi", - "lib/ocaml/Stdlib_Intl_DateTimeFormat.cmj", - "lib/ocaml/Stdlib_Intl_DateTimeFormat.cmt", - "lib/ocaml/Stdlib_Intl_DateTimeFormat.res", - "lib/ocaml/Stdlib_Intl_ListFormat.cmi", - "lib/ocaml/Stdlib_Intl_ListFormat.cmj", - "lib/ocaml/Stdlib_Intl_ListFormat.cmt", - "lib/ocaml/Stdlib_Intl_ListFormat.res", - "lib/ocaml/Stdlib_Intl_Locale.cmi", - "lib/ocaml/Stdlib_Intl_Locale.cmj", - "lib/ocaml/Stdlib_Intl_Locale.cmt", - "lib/ocaml/Stdlib_Intl_Locale.res", - "lib/ocaml/Stdlib_Intl_NumberFormat.cmi", - "lib/ocaml/Stdlib_Intl_NumberFormat.cmj", - "lib/ocaml/Stdlib_Intl_NumberFormat.cmt", - "lib/ocaml/Stdlib_Intl_NumberFormat.res", - "lib/ocaml/Stdlib_Intl_NumberFormat_Grouping.cmi", - "lib/ocaml/Stdlib_Intl_NumberFormat_Grouping.cmj", - "lib/ocaml/Stdlib_Intl_NumberFormat_Grouping.cmt", - "lib/ocaml/Stdlib_Intl_NumberFormat_Grouping.res", - "lib/ocaml/Stdlib_Intl_PluralRules.cmi", - "lib/ocaml/Stdlib_Intl_PluralRules.cmj", - "lib/ocaml/Stdlib_Intl_PluralRules.cmt", - "lib/ocaml/Stdlib_Intl_PluralRules.res", - "lib/ocaml/Stdlib_Intl_RelativeTimeFormat.cmi", - "lib/ocaml/Stdlib_Intl_RelativeTimeFormat.cmj", - "lib/ocaml/Stdlib_Intl_RelativeTimeFormat.cmt", - "lib/ocaml/Stdlib_Intl_RelativeTimeFormat.res", - "lib/ocaml/Stdlib_Intl_Segmenter.cmi", - "lib/ocaml/Stdlib_Intl_Segmenter.cmj", - "lib/ocaml/Stdlib_Intl_Segmenter.cmt", - "lib/ocaml/Stdlib_Intl_Segmenter.res", - "lib/ocaml/Stdlib_Intl_Segments.cmi", - "lib/ocaml/Stdlib_Intl_Segments.cmj", - "lib/ocaml/Stdlib_Intl_Segments.cmt", - "lib/ocaml/Stdlib_Intl_Segments.res", - "lib/ocaml/Stdlib_Iterable.cmi", - "lib/ocaml/Stdlib_Iterable.cmj", - "lib/ocaml/Stdlib_Iterable.cmt", - "lib/ocaml/Stdlib_Iterable.cmti", - "lib/ocaml/Stdlib_Iterable.res", - "lib/ocaml/Stdlib_Iterable.resi", - "lib/ocaml/Stdlib_IterableIterator.cmi", - "lib/ocaml/Stdlib_IterableIterator.cmj", - "lib/ocaml/Stdlib_IterableIterator.cmt", - "lib/ocaml/Stdlib_IterableIterator.cmti", - "lib/ocaml/Stdlib_IterableIterator.res", - "lib/ocaml/Stdlib_IterableIterator.resi", - "lib/ocaml/Stdlib_Iterator.cmi", - "lib/ocaml/Stdlib_Iterator.cmj", - "lib/ocaml/Stdlib_Iterator.cmt", - "lib/ocaml/Stdlib_Iterator.cmti", - "lib/ocaml/Stdlib_Iterator.res", - "lib/ocaml/Stdlib_Iterator.resi", - "lib/ocaml/Stdlib_IteratorObject.cmi", - "lib/ocaml/Stdlib_IteratorObject.cmj", - "lib/ocaml/Stdlib_IteratorObject.cmt", - "lib/ocaml/Stdlib_IteratorObject.cmti", - "lib/ocaml/Stdlib_IteratorObject.res", - "lib/ocaml/Stdlib_IteratorObject.resi", - "lib/ocaml/Stdlib_JSON.cmi", - "lib/ocaml/Stdlib_JSON.cmj", - "lib/ocaml/Stdlib_JSON.cmt", - "lib/ocaml/Stdlib_JSON.cmti", - "lib/ocaml/Stdlib_JSON.res", - "lib/ocaml/Stdlib_JSON.resi", - "lib/ocaml/Stdlib_JsError.cmi", - "lib/ocaml/Stdlib_JsError.cmj", - "lib/ocaml/Stdlib_JsError.cmt", - "lib/ocaml/Stdlib_JsError.cmti", - "lib/ocaml/Stdlib_JsError.res", - "lib/ocaml/Stdlib_JsError.resi", - "lib/ocaml/Stdlib_JsExn.cmi", - "lib/ocaml/Stdlib_JsExn.cmj", - "lib/ocaml/Stdlib_JsExn.cmt", - "lib/ocaml/Stdlib_JsExn.cmti", - "lib/ocaml/Stdlib_JsExn.res", - "lib/ocaml/Stdlib_JsExn.resi", - "lib/ocaml/Stdlib_Lazy.cmi", - "lib/ocaml/Stdlib_Lazy.cmj", - "lib/ocaml/Stdlib_Lazy.cmt", - "lib/ocaml/Stdlib_Lazy.cmti", - "lib/ocaml/Stdlib_Lazy.res", - "lib/ocaml/Stdlib_Lazy.resi", - "lib/ocaml/Stdlib_List.cmi", - "lib/ocaml/Stdlib_List.cmj", - "lib/ocaml/Stdlib_List.cmt", - "lib/ocaml/Stdlib_List.cmti", - "lib/ocaml/Stdlib_List.res", - "lib/ocaml/Stdlib_List.resi", - "lib/ocaml/Stdlib_Map.cmi", - "lib/ocaml/Stdlib_Map.cmj", - "lib/ocaml/Stdlib_Map.cmt", - "lib/ocaml/Stdlib_Map.cmti", - "lib/ocaml/Stdlib_Map.res", - "lib/ocaml/Stdlib_Map.resi", - "lib/ocaml/Stdlib_Math.cmi", - "lib/ocaml/Stdlib_Math.cmj", - "lib/ocaml/Stdlib_Math.cmt", - "lib/ocaml/Stdlib_Math.cmti", - "lib/ocaml/Stdlib_Math.res", - "lib/ocaml/Stdlib_Math.resi", - "lib/ocaml/Stdlib_Null.cmi", - "lib/ocaml/Stdlib_Null.cmj", - "lib/ocaml/Stdlib_Null.cmt", - "lib/ocaml/Stdlib_Null.cmti", - "lib/ocaml/Stdlib_Null.res", - "lib/ocaml/Stdlib_Null.resi", - "lib/ocaml/Stdlib_Nullable.cmi", - "lib/ocaml/Stdlib_Nullable.cmj", - "lib/ocaml/Stdlib_Nullable.cmt", - "lib/ocaml/Stdlib_Nullable.cmti", - "lib/ocaml/Stdlib_Nullable.res", - "lib/ocaml/Stdlib_Nullable.resi", - "lib/ocaml/Stdlib_Object.cmi", - "lib/ocaml/Stdlib_Object.cmj", - "lib/ocaml/Stdlib_Object.cmt", - "lib/ocaml/Stdlib_Object.res", - "lib/ocaml/Stdlib_Option.cmi", - "lib/ocaml/Stdlib_Option.cmj", - "lib/ocaml/Stdlib_Option.cmt", - "lib/ocaml/Stdlib_Option.cmti", - "lib/ocaml/Stdlib_Option.res", - "lib/ocaml/Stdlib_Option.resi", - "lib/ocaml/Stdlib_Ordering.cmi", - "lib/ocaml/Stdlib_Ordering.cmj", - "lib/ocaml/Stdlib_Ordering.cmt", - "lib/ocaml/Stdlib_Ordering.res", - "lib/ocaml/Stdlib_Pair.cmi", - "lib/ocaml/Stdlib_Pair.cmj", - "lib/ocaml/Stdlib_Pair.cmt", - "lib/ocaml/Stdlib_Pair.res", - "lib/ocaml/Stdlib_Promise.cmi", - "lib/ocaml/Stdlib_Promise.cmj", - "lib/ocaml/Stdlib_Promise.cmt", - "lib/ocaml/Stdlib_Promise.cmti", - "lib/ocaml/Stdlib_Promise.res", - "lib/ocaml/Stdlib_Promise.resi", - "lib/ocaml/Stdlib_RegExp.cmi", - "lib/ocaml/Stdlib_RegExp.cmj", - "lib/ocaml/Stdlib_RegExp.cmt", - "lib/ocaml/Stdlib_RegExp.cmti", - "lib/ocaml/Stdlib_RegExp.res", - "lib/ocaml/Stdlib_RegExp.resi", - "lib/ocaml/Stdlib_Result.cmi", - "lib/ocaml/Stdlib_Result.cmj", - "lib/ocaml/Stdlib_Result.cmt", - "lib/ocaml/Stdlib_Result.cmti", - "lib/ocaml/Stdlib_Result.res", - "lib/ocaml/Stdlib_Result.resi", - "lib/ocaml/Stdlib_Set.cmi", - "lib/ocaml/Stdlib_Set.cmj", - "lib/ocaml/Stdlib_Set.cmt", - "lib/ocaml/Stdlib_Set.cmti", - "lib/ocaml/Stdlib_Set.res", - "lib/ocaml/Stdlib_Set.resi", - "lib/ocaml/Stdlib_String.cmi", - "lib/ocaml/Stdlib_String.cmj", - "lib/ocaml/Stdlib_String.cmt", - "lib/ocaml/Stdlib_String.cmti", - "lib/ocaml/Stdlib_String.res", - "lib/ocaml/Stdlib_String.resi", - "lib/ocaml/Stdlib_Symbol.cmi", - "lib/ocaml/Stdlib_Symbol.cmj", - "lib/ocaml/Stdlib_Symbol.cmt", - "lib/ocaml/Stdlib_Symbol.cmti", - "lib/ocaml/Stdlib_Symbol.res", - "lib/ocaml/Stdlib_Symbol.resi", - "lib/ocaml/Stdlib_TaggedTemplate.cmi", - "lib/ocaml/Stdlib_TaggedTemplate.cmj", - "lib/ocaml/Stdlib_TaggedTemplate.cmt", - "lib/ocaml/Stdlib_TaggedTemplate.cmti", - "lib/ocaml/Stdlib_TaggedTemplate.res", - "lib/ocaml/Stdlib_TaggedTemplate.resi", - "lib/ocaml/Stdlib_Temporal.cmi", - "lib/ocaml/Stdlib_Temporal.cmj", - "lib/ocaml/Stdlib_Temporal.cmt", - "lib/ocaml/Stdlib_Temporal.res", - "lib/ocaml/Stdlib_Temporal_Common.cmi", - "lib/ocaml/Stdlib_Temporal_Common.cmj", - "lib/ocaml/Stdlib_Temporal_Common.cmt", - "lib/ocaml/Stdlib_Temporal_Common.res", - "lib/ocaml/Stdlib_Temporal_Duration.cmi", - "lib/ocaml/Stdlib_Temporal_Duration.cmj", - "lib/ocaml/Stdlib_Temporal_Duration.cmt", - "lib/ocaml/Stdlib_Temporal_Duration.res", - "lib/ocaml/Stdlib_Temporal_Instant.cmi", - "lib/ocaml/Stdlib_Temporal_Instant.cmj", - "lib/ocaml/Stdlib_Temporal_Instant.cmt", - "lib/ocaml/Stdlib_Temporal_Instant.res", - "lib/ocaml/Stdlib_Temporal_Now.cmi", - "lib/ocaml/Stdlib_Temporal_Now.cmj", - "lib/ocaml/Stdlib_Temporal_Now.cmt", - "lib/ocaml/Stdlib_Temporal_Now.res", - "lib/ocaml/Stdlib_Temporal_PlainDate.cmi", - "lib/ocaml/Stdlib_Temporal_PlainDate.cmj", - "lib/ocaml/Stdlib_Temporal_PlainDate.cmt", - "lib/ocaml/Stdlib_Temporal_PlainDate.res", - "lib/ocaml/Stdlib_Temporal_PlainDateTime.cmi", - "lib/ocaml/Stdlib_Temporal_PlainDateTime.cmj", - "lib/ocaml/Stdlib_Temporal_PlainDateTime.cmt", - "lib/ocaml/Stdlib_Temporal_PlainDateTime.res", - "lib/ocaml/Stdlib_Temporal_PlainMonthDay.cmi", - "lib/ocaml/Stdlib_Temporal_PlainMonthDay.cmj", - "lib/ocaml/Stdlib_Temporal_PlainMonthDay.cmt", - "lib/ocaml/Stdlib_Temporal_PlainMonthDay.res", - "lib/ocaml/Stdlib_Temporal_PlainTime.cmi", - "lib/ocaml/Stdlib_Temporal_PlainTime.cmj", - "lib/ocaml/Stdlib_Temporal_PlainTime.cmt", - "lib/ocaml/Stdlib_Temporal_PlainTime.res", - "lib/ocaml/Stdlib_Temporal_PlainYearMonth.cmi", - "lib/ocaml/Stdlib_Temporal_PlainYearMonth.cmj", - "lib/ocaml/Stdlib_Temporal_PlainYearMonth.cmt", - "lib/ocaml/Stdlib_Temporal_PlainYearMonth.res", - "lib/ocaml/Stdlib_Temporal_ZonedDateTime.cmi", - "lib/ocaml/Stdlib_Temporal_ZonedDateTime.cmj", - "lib/ocaml/Stdlib_Temporal_ZonedDateTime.cmt", - "lib/ocaml/Stdlib_Temporal_ZonedDateTime.res", - "lib/ocaml/Stdlib_Type.cmi", - "lib/ocaml/Stdlib_Type.cmj", - "lib/ocaml/Stdlib_Type.cmt", - "lib/ocaml/Stdlib_Type.cmti", - "lib/ocaml/Stdlib_Type.res", - "lib/ocaml/Stdlib_Type.resi", - "lib/ocaml/Stdlib_TypedArray.cmi", - "lib/ocaml/Stdlib_TypedArray.cmj", - "lib/ocaml/Stdlib_TypedArray.cmt", - "lib/ocaml/Stdlib_TypedArray.res", - "lib/ocaml/Stdlib_Uint16Array.cmi", - "lib/ocaml/Stdlib_Uint16Array.cmj", - "lib/ocaml/Stdlib_Uint16Array.cmt", - "lib/ocaml/Stdlib_Uint16Array.res", - "lib/ocaml/Stdlib_Uint32Array.cmi", - "lib/ocaml/Stdlib_Uint32Array.cmj", - "lib/ocaml/Stdlib_Uint32Array.cmt", - "lib/ocaml/Stdlib_Uint32Array.res", - "lib/ocaml/Stdlib_Uint8Array.cmi", - "lib/ocaml/Stdlib_Uint8Array.cmj", - "lib/ocaml/Stdlib_Uint8Array.cmt", - "lib/ocaml/Stdlib_Uint8Array.res", - "lib/ocaml/Stdlib_Uint8ClampedArray.cmi", - "lib/ocaml/Stdlib_Uint8ClampedArray.cmj", - "lib/ocaml/Stdlib_Uint8ClampedArray.cmt", - "lib/ocaml/Stdlib_Uint8ClampedArray.res", - "lib/ocaml/Stdlib_WeakMap.cmi", - "lib/ocaml/Stdlib_WeakMap.cmj", - "lib/ocaml/Stdlib_WeakMap.cmt", - "lib/ocaml/Stdlib_WeakMap.res", - "lib/ocaml/Stdlib_WeakSet.cmi", - "lib/ocaml/Stdlib_WeakSet.cmj", - "lib/ocaml/Stdlib_WeakSet.cmt", - "lib/ocaml/Stdlib_WeakSet.res", + "lib/rescript/Dom.cmi", + "lib/rescript/Dom.cmj", + "lib/rescript/Dom.cmt", + "lib/rescript/Dom_storage.cmi", + "lib/rescript/Dom_storage.cmj", + "lib/rescript/Dom_storage.cmt", + "lib/rescript/Dom_storage2.cmi", + "lib/rescript/Dom_storage2.cmj", + "lib/rescript/Dom_storage2.cmt", + "lib/rescript/Jsx.cmi", + "lib/rescript/Jsx.cmj", + "lib/rescript/Jsx.cmt", + "lib/rescript/JsxDOM.cmi", + "lib/rescript/JsxDOM.cmj", + "lib/rescript/JsxDOM.cmt", + "lib/rescript/JsxDOMStyle.cmi", + "lib/rescript/JsxDOMStyle.cmj", + "lib/rescript/JsxDOMStyle.cmt", + "lib/rescript/JsxEvent.cmi", + "lib/rescript/JsxEvent.cmj", + "lib/rescript/JsxEvent.cmt", + "lib/rescript/Obj.cmi", + "lib/rescript/Obj.cmj", + "lib/rescript/Obj.cmt", + "lib/rescript/Pervasives.cmi", + "lib/rescript/Pervasives.cmj", + "lib/rescript/Pervasives.cmt", + "lib/rescript/Primitive_array.cmi", + "lib/rescript/Primitive_array.cmj", + "lib/rescript/Primitive_array.cmt", + "lib/rescript/Primitive_array_extern.cmi", + "lib/rescript/Primitive_array_extern.cmj", + "lib/rescript/Primitive_array_extern.cmt", + "lib/rescript/Primitive_bigint.cmi", + "lib/rescript/Primitive_bigint.cmj", + "lib/rescript/Primitive_bigint.cmt", + "lib/rescript/Primitive_bool.cmi", + "lib/rescript/Primitive_bool.cmj", + "lib/rescript/Primitive_bool.cmt", + "lib/rescript/Primitive_dict.cmi", + "lib/rescript/Primitive_dict.cmj", + "lib/rescript/Primitive_dict.cmt", + "lib/rescript/Primitive_exceptions.cmi", + "lib/rescript/Primitive_exceptions.cmj", + "lib/rescript/Primitive_exceptions.cmt", + "lib/rescript/Primitive_exceptions.cmti", + "lib/rescript/Primitive_float.cmi", + "lib/rescript/Primitive_float.cmj", + "lib/rescript/Primitive_float.cmt", + "lib/rescript/Primitive_float_extern.cmi", + "lib/rescript/Primitive_float_extern.cmj", + "lib/rescript/Primitive_float_extern.cmt", + "lib/rescript/Primitive_hash.cmi", + "lib/rescript/Primitive_hash.cmj", + "lib/rescript/Primitive_hash.cmt", + "lib/rescript/Primitive_hash.cmti", + "lib/rescript/Primitive_int.cmi", + "lib/rescript/Primitive_int.cmj", + "lib/rescript/Primitive_int.cmt", + "lib/rescript/Primitive_int_extern.cmi", + "lib/rescript/Primitive_int_extern.cmj", + "lib/rescript/Primitive_int_extern.cmt", + "lib/rescript/Primitive_js_extern.cmi", + "lib/rescript/Primitive_js_extern.cmj", + "lib/rescript/Primitive_js_extern.cmt", + "lib/rescript/Primitive_list.cmi", + "lib/rescript/Primitive_list.cmj", + "lib/rescript/Primitive_list.cmt", + "lib/rescript/Primitive_list.cmti", + "lib/rescript/Primitive_module.cmi", + "lib/rescript/Primitive_module.cmj", + "lib/rescript/Primitive_module.cmt", + "lib/rescript/Primitive_module.cmti", + "lib/rescript/Primitive_object.cmi", + "lib/rescript/Primitive_object.cmj", + "lib/rescript/Primitive_object.cmt", + "lib/rescript/Primitive_object.cmti", + "lib/rescript/Primitive_object_extern.cmi", + "lib/rescript/Primitive_object_extern.cmj", + "lib/rescript/Primitive_object_extern.cmt", + "lib/rescript/Primitive_option.cmi", + "lib/rescript/Primitive_option.cmj", + "lib/rescript/Primitive_option.cmt", + "lib/rescript/Primitive_option.cmti", + "lib/rescript/Primitive_promise.cmi", + "lib/rescript/Primitive_promise.cmj", + "lib/rescript/Primitive_promise.cmt", + "lib/rescript/Primitive_string.cmi", + "lib/rescript/Primitive_string.cmj", + "lib/rescript/Primitive_string.cmt", + "lib/rescript/Primitive_string_extern.cmi", + "lib/rescript/Primitive_string_extern.cmj", + "lib/rescript/Primitive_string_extern.cmt", + "lib/rescript/RescriptTools.cmi", + "lib/rescript/RescriptTools.cmj", + "lib/rescript/RescriptTools.cmt", + "lib/rescript/RescriptTools_Docgen.cmi", + "lib/rescript/RescriptTools_Docgen.cmj", + "lib/rescript/RescriptTools_Docgen.cmt", + "lib/rescript/RescriptTools_Docgen.cmti", + "lib/rescript/RescriptTools_ExtractCodeBlocks.cmi", + "lib/rescript/RescriptTools_ExtractCodeBlocks.cmj", + "lib/rescript/RescriptTools_ExtractCodeBlocks.cmt", + "lib/rescript/Stdlib.cmi", + "lib/rescript/Stdlib.cmj", + "lib/rescript/Stdlib.cmt", + "lib/rescript/Stdlib_Array.cmi", + "lib/rescript/Stdlib_Array.cmj", + "lib/rescript/Stdlib_Array.cmt", + "lib/rescript/Stdlib_Array.cmti", + "lib/rescript/Stdlib_ArrayBuffer.cmi", + "lib/rescript/Stdlib_ArrayBuffer.cmj", + "lib/rescript/Stdlib_ArrayBuffer.cmt", + "lib/rescript/Stdlib_ArrayBuffer.cmti", + "lib/rescript/Stdlib_AsyncGenerator.cmi", + "lib/rescript/Stdlib_AsyncGenerator.cmj", + "lib/rescript/Stdlib_AsyncGenerator.cmt", + "lib/rescript/Stdlib_AsyncGenerator.cmti", + "lib/rescript/Stdlib_AsyncIterable.cmi", + "lib/rescript/Stdlib_AsyncIterable.cmj", + "lib/rescript/Stdlib_AsyncIterable.cmt", + "lib/rescript/Stdlib_AsyncIterable.cmti", + "lib/rescript/Stdlib_AsyncIterableIterator.cmi", + "lib/rescript/Stdlib_AsyncIterableIterator.cmj", + "lib/rescript/Stdlib_AsyncIterableIterator.cmt", + "lib/rescript/Stdlib_AsyncIterableIterator.cmti", + "lib/rescript/Stdlib_AsyncIterator.cmi", + "lib/rescript/Stdlib_AsyncIterator.cmj", + "lib/rescript/Stdlib_AsyncIterator.cmt", + "lib/rescript/Stdlib_AsyncIterator.cmti", + "lib/rescript/Stdlib_BigInt.cmi", + "lib/rescript/Stdlib_BigInt.cmj", + "lib/rescript/Stdlib_BigInt.cmt", + "lib/rescript/Stdlib_BigInt.cmti", + "lib/rescript/Stdlib_BigInt64Array.cmi", + "lib/rescript/Stdlib_BigInt64Array.cmj", + "lib/rescript/Stdlib_BigInt64Array.cmt", + "lib/rescript/Stdlib_BigUint64Array.cmi", + "lib/rescript/Stdlib_BigUint64Array.cmj", + "lib/rescript/Stdlib_BigUint64Array.cmt", + "lib/rescript/Stdlib_Blob.cmi", + "lib/rescript/Stdlib_Blob.cmj", + "lib/rescript/Stdlib_Blob.cmt", + "lib/rescript/Stdlib_Bool.cmi", + "lib/rescript/Stdlib_Bool.cmj", + "lib/rescript/Stdlib_Bool.cmt", + "lib/rescript/Stdlib_Bool.cmti", + "lib/rescript/Stdlib_Console.cmi", + "lib/rescript/Stdlib_Console.cmj", + "lib/rescript/Stdlib_Console.cmt", + "lib/rescript/Stdlib_Console.cmti", + "lib/rescript/Stdlib_DataView.cmi", + "lib/rescript/Stdlib_DataView.cmj", + "lib/rescript/Stdlib_DataView.cmt", + "lib/rescript/Stdlib_DataView.cmti", + "lib/rescript/Stdlib_Date.cmi", + "lib/rescript/Stdlib_Date.cmj", + "lib/rescript/Stdlib_Date.cmt", + "lib/rescript/Stdlib_Date.cmti", + "lib/rescript/Stdlib_Dict.cmi", + "lib/rescript/Stdlib_Dict.cmj", + "lib/rescript/Stdlib_Dict.cmt", + "lib/rescript/Stdlib_Dict.cmti", + "lib/rescript/Stdlib_File.cmi", + "lib/rescript/Stdlib_File.cmj", + "lib/rescript/Stdlib_File.cmt", + "lib/rescript/Stdlib_Float.cmi", + "lib/rescript/Stdlib_Float.cmj", + "lib/rescript/Stdlib_Float.cmt", + "lib/rescript/Stdlib_Float.cmti", + "lib/rescript/Stdlib_Float32Array.cmi", + "lib/rescript/Stdlib_Float32Array.cmj", + "lib/rescript/Stdlib_Float32Array.cmt", + "lib/rescript/Stdlib_Float64Array.cmi", + "lib/rescript/Stdlib_Float64Array.cmj", + "lib/rescript/Stdlib_Float64Array.cmt", + "lib/rescript/Stdlib_Generator.cmi", + "lib/rescript/Stdlib_Generator.cmj", + "lib/rescript/Stdlib_Generator.cmt", + "lib/rescript/Stdlib_Generator.cmti", + "lib/rescript/Stdlib_Global.cmi", + "lib/rescript/Stdlib_Global.cmj", + "lib/rescript/Stdlib_Global.cmt", + "lib/rescript/Stdlib_Global.cmti", + "lib/rescript/Stdlib_Int.cmi", + "lib/rescript/Stdlib_Int.cmj", + "lib/rescript/Stdlib_Int.cmt", + "lib/rescript/Stdlib_Int.cmti", + "lib/rescript/Stdlib_Int16Array.cmi", + "lib/rescript/Stdlib_Int16Array.cmj", + "lib/rescript/Stdlib_Int16Array.cmt", + "lib/rescript/Stdlib_Int32Array.cmi", + "lib/rescript/Stdlib_Int32Array.cmj", + "lib/rescript/Stdlib_Int32Array.cmt", + "lib/rescript/Stdlib_Int8Array.cmi", + "lib/rescript/Stdlib_Int8Array.cmj", + "lib/rescript/Stdlib_Int8Array.cmt", + "lib/rescript/Stdlib_Intl.cmi", + "lib/rescript/Stdlib_Intl.cmj", + "lib/rescript/Stdlib_Intl.cmt", + "lib/rescript/Stdlib_Intl_Collator.cmi", + "lib/rescript/Stdlib_Intl_Collator.cmj", + "lib/rescript/Stdlib_Intl_Collator.cmt", + "lib/rescript/Stdlib_Intl_Common.cmi", + "lib/rescript/Stdlib_Intl_Common.cmj", + "lib/rescript/Stdlib_Intl_Common.cmt", + "lib/rescript/Stdlib_Intl_DateTimeFormat.cmi", + "lib/rescript/Stdlib_Intl_DateTimeFormat.cmj", + "lib/rescript/Stdlib_Intl_DateTimeFormat.cmt", + "lib/rescript/Stdlib_Intl_ListFormat.cmi", + "lib/rescript/Stdlib_Intl_ListFormat.cmj", + "lib/rescript/Stdlib_Intl_ListFormat.cmt", + "lib/rescript/Stdlib_Intl_Locale.cmi", + "lib/rescript/Stdlib_Intl_Locale.cmj", + "lib/rescript/Stdlib_Intl_Locale.cmt", + "lib/rescript/Stdlib_Intl_NumberFormat.cmi", + "lib/rescript/Stdlib_Intl_NumberFormat.cmj", + "lib/rescript/Stdlib_Intl_NumberFormat.cmt", + "lib/rescript/Stdlib_Intl_NumberFormat_Grouping.cmi", + "lib/rescript/Stdlib_Intl_NumberFormat_Grouping.cmj", + "lib/rescript/Stdlib_Intl_NumberFormat_Grouping.cmt", + "lib/rescript/Stdlib_Intl_PluralRules.cmi", + "lib/rescript/Stdlib_Intl_PluralRules.cmj", + "lib/rescript/Stdlib_Intl_PluralRules.cmt", + "lib/rescript/Stdlib_Intl_RelativeTimeFormat.cmi", + "lib/rescript/Stdlib_Intl_RelativeTimeFormat.cmj", + "lib/rescript/Stdlib_Intl_RelativeTimeFormat.cmt", + "lib/rescript/Stdlib_Intl_Segmenter.cmi", + "lib/rescript/Stdlib_Intl_Segmenter.cmj", + "lib/rescript/Stdlib_Intl_Segmenter.cmt", + "lib/rescript/Stdlib_Intl_Segments.cmi", + "lib/rescript/Stdlib_Intl_Segments.cmj", + "lib/rescript/Stdlib_Intl_Segments.cmt", + "lib/rescript/Stdlib_Iterable.cmi", + "lib/rescript/Stdlib_Iterable.cmj", + "lib/rescript/Stdlib_Iterable.cmt", + "lib/rescript/Stdlib_Iterable.cmti", + "lib/rescript/Stdlib_IterableIterator.cmi", + "lib/rescript/Stdlib_IterableIterator.cmj", + "lib/rescript/Stdlib_IterableIterator.cmt", + "lib/rescript/Stdlib_IterableIterator.cmti", + "lib/rescript/Stdlib_Iterator.cmi", + "lib/rescript/Stdlib_Iterator.cmj", + "lib/rescript/Stdlib_Iterator.cmt", + "lib/rescript/Stdlib_Iterator.cmti", + "lib/rescript/Stdlib_IteratorObject.cmi", + "lib/rescript/Stdlib_IteratorObject.cmj", + "lib/rescript/Stdlib_IteratorObject.cmt", + "lib/rescript/Stdlib_IteratorObject.cmti", + "lib/rescript/Stdlib_JSON.cmi", + "lib/rescript/Stdlib_JSON.cmj", + "lib/rescript/Stdlib_JSON.cmt", + "lib/rescript/Stdlib_JSON.cmti", + "lib/rescript/Stdlib_JsError.cmi", + "lib/rescript/Stdlib_JsError.cmj", + "lib/rescript/Stdlib_JsError.cmt", + "lib/rescript/Stdlib_JsError.cmti", + "lib/rescript/Stdlib_JsExn.cmi", + "lib/rescript/Stdlib_JsExn.cmj", + "lib/rescript/Stdlib_JsExn.cmt", + "lib/rescript/Stdlib_JsExn.cmti", + "lib/rescript/Stdlib_Lazy.cmi", + "lib/rescript/Stdlib_Lazy.cmj", + "lib/rescript/Stdlib_Lazy.cmt", + "lib/rescript/Stdlib_Lazy.cmti", + "lib/rescript/Stdlib_List.cmi", + "lib/rescript/Stdlib_List.cmj", + "lib/rescript/Stdlib_List.cmt", + "lib/rescript/Stdlib_List.cmti", + "lib/rescript/Stdlib_Map.cmi", + "lib/rescript/Stdlib_Map.cmj", + "lib/rescript/Stdlib_Map.cmt", + "lib/rescript/Stdlib_Map.cmti", + "lib/rescript/Stdlib_Math.cmi", + "lib/rescript/Stdlib_Math.cmj", + "lib/rescript/Stdlib_Math.cmt", + "lib/rescript/Stdlib_Math.cmti", + "lib/rescript/Stdlib_Null.cmi", + "lib/rescript/Stdlib_Null.cmj", + "lib/rescript/Stdlib_Null.cmt", + "lib/rescript/Stdlib_Null.cmti", + "lib/rescript/Stdlib_Nullable.cmi", + "lib/rescript/Stdlib_Nullable.cmj", + "lib/rescript/Stdlib_Nullable.cmt", + "lib/rescript/Stdlib_Nullable.cmti", + "lib/rescript/Stdlib_Object.cmi", + "lib/rescript/Stdlib_Object.cmj", + "lib/rescript/Stdlib_Object.cmt", + "lib/rescript/Stdlib_Option.cmi", + "lib/rescript/Stdlib_Option.cmj", + "lib/rescript/Stdlib_Option.cmt", + "lib/rescript/Stdlib_Option.cmti", + "lib/rescript/Stdlib_Ordering.cmi", + "lib/rescript/Stdlib_Ordering.cmj", + "lib/rescript/Stdlib_Ordering.cmt", + "lib/rescript/Stdlib_Pair.cmi", + "lib/rescript/Stdlib_Pair.cmj", + "lib/rescript/Stdlib_Pair.cmt", + "lib/rescript/Stdlib_Promise.cmi", + "lib/rescript/Stdlib_Promise.cmj", + "lib/rescript/Stdlib_Promise.cmt", + "lib/rescript/Stdlib_Promise.cmti", + "lib/rescript/Stdlib_RegExp.cmi", + "lib/rescript/Stdlib_RegExp.cmj", + "lib/rescript/Stdlib_RegExp.cmt", + "lib/rescript/Stdlib_RegExp.cmti", + "lib/rescript/Stdlib_Result.cmi", + "lib/rescript/Stdlib_Result.cmj", + "lib/rescript/Stdlib_Result.cmt", + "lib/rescript/Stdlib_Result.cmti", + "lib/rescript/Stdlib_Set.cmi", + "lib/rescript/Stdlib_Set.cmj", + "lib/rescript/Stdlib_Set.cmt", + "lib/rescript/Stdlib_Set.cmti", + "lib/rescript/Stdlib_String.cmi", + "lib/rescript/Stdlib_String.cmj", + "lib/rescript/Stdlib_String.cmt", + "lib/rescript/Stdlib_String.cmti", + "lib/rescript/Stdlib_Symbol.cmi", + "lib/rescript/Stdlib_Symbol.cmj", + "lib/rescript/Stdlib_Symbol.cmt", + "lib/rescript/Stdlib_Symbol.cmti", + "lib/rescript/Stdlib_TaggedTemplate.cmi", + "lib/rescript/Stdlib_TaggedTemplate.cmj", + "lib/rescript/Stdlib_TaggedTemplate.cmt", + "lib/rescript/Stdlib_TaggedTemplate.cmti", + "lib/rescript/Stdlib_Temporal.cmi", + "lib/rescript/Stdlib_Temporal.cmj", + "lib/rescript/Stdlib_Temporal.cmt", + "lib/rescript/Stdlib_Temporal_Common.cmi", + "lib/rescript/Stdlib_Temporal_Common.cmj", + "lib/rescript/Stdlib_Temporal_Common.cmt", + "lib/rescript/Stdlib_Temporal_Duration.cmi", + "lib/rescript/Stdlib_Temporal_Duration.cmj", + "lib/rescript/Stdlib_Temporal_Duration.cmt", + "lib/rescript/Stdlib_Temporal_Instant.cmi", + "lib/rescript/Stdlib_Temporal_Instant.cmj", + "lib/rescript/Stdlib_Temporal_Instant.cmt", + "lib/rescript/Stdlib_Temporal_Now.cmi", + "lib/rescript/Stdlib_Temporal_Now.cmj", + "lib/rescript/Stdlib_Temporal_Now.cmt", + "lib/rescript/Stdlib_Temporal_PlainDate.cmi", + "lib/rescript/Stdlib_Temporal_PlainDate.cmj", + "lib/rescript/Stdlib_Temporal_PlainDate.cmt", + "lib/rescript/Stdlib_Temporal_PlainDateTime.cmi", + "lib/rescript/Stdlib_Temporal_PlainDateTime.cmj", + "lib/rescript/Stdlib_Temporal_PlainDateTime.cmt", + "lib/rescript/Stdlib_Temporal_PlainMonthDay.cmi", + "lib/rescript/Stdlib_Temporal_PlainMonthDay.cmj", + "lib/rescript/Stdlib_Temporal_PlainMonthDay.cmt", + "lib/rescript/Stdlib_Temporal_PlainTime.cmi", + "lib/rescript/Stdlib_Temporal_PlainTime.cmj", + "lib/rescript/Stdlib_Temporal_PlainTime.cmt", + "lib/rescript/Stdlib_Temporal_PlainYearMonth.cmi", + "lib/rescript/Stdlib_Temporal_PlainYearMonth.cmj", + "lib/rescript/Stdlib_Temporal_PlainYearMonth.cmt", + "lib/rescript/Stdlib_Temporal_ZonedDateTime.cmi", + "lib/rescript/Stdlib_Temporal_ZonedDateTime.cmj", + "lib/rescript/Stdlib_Temporal_ZonedDateTime.cmt", + "lib/rescript/Stdlib_Type.cmi", + "lib/rescript/Stdlib_Type.cmj", + "lib/rescript/Stdlib_Type.cmt", + "lib/rescript/Stdlib_Type.cmti", + "lib/rescript/Stdlib_TypedArray.cmi", + "lib/rescript/Stdlib_TypedArray.cmj", + "lib/rescript/Stdlib_TypedArray.cmt", + "lib/rescript/Stdlib_Uint16Array.cmi", + "lib/rescript/Stdlib_Uint16Array.cmj", + "lib/rescript/Stdlib_Uint16Array.cmt", + "lib/rescript/Stdlib_Uint32Array.cmi", + "lib/rescript/Stdlib_Uint32Array.cmj", + "lib/rescript/Stdlib_Uint32Array.cmt", + "lib/rescript/Stdlib_Uint8Array.cmi", + "lib/rescript/Stdlib_Uint8Array.cmj", + "lib/rescript/Stdlib_Uint8Array.cmt", + "lib/rescript/Stdlib_Uint8ClampedArray.cmi", + "lib/rescript/Stdlib_Uint8ClampedArray.cmj", + "lib/rescript/Stdlib_Uint8ClampedArray.cmt", + "lib/rescript/Stdlib_WeakMap.cmi", + "lib/rescript/Stdlib_WeakMap.cmj", + "lib/rescript/Stdlib_WeakMap.cmt", + "lib/rescript/Stdlib_WeakSet.cmi", + "lib/rescript/Stdlib_WeakSet.cmj", + "lib/rescript/Stdlib_WeakSet.cmt", "package.json" ], "@rescript/belt": [ diff --git a/packages/playground/scripts/generate_cmijs.mjs b/packages/playground/scripts/generate_cmijs.mjs index 614f3d99b8d..2c83343d298 100644 --- a/packages/playground/scripts/generate_cmijs.mjs +++ b/packages/playground/scripts/generate_cmijs.mjs @@ -5,7 +5,7 @@ /* * You need to build cmij files with the same rescript version as the compiler bundle. * - * This script extracts the cmi / cmj files of packages/@rescript/runtime/lib/ocaml + * This script extracts the cmi / cmj files of packages/@rescript/runtime/lib/rescript * and of every dependency listed in the playground package's rescript.json, * creates a cmij.js file for each library and puts them in the playground's * packages directory. @@ -44,10 +44,10 @@ for (const pkgName of packages) { * @param {string} pkgName */ function buildCmij(pkgDir, pkgName) { - const libOcamlFolder = path.join( + const artifactFolder = path.join( pkgDir, "lib", - "ocaml", + "rescript", ); const outputFolder = path.join(playgroundPackagesDir, pkgName); @@ -55,10 +55,10 @@ function buildCmij(pkgDir, pkgName) { const cmijFile = path.join(outputFolder, "cmij.js"); const files = fs - .readdirSync(libOcamlFolder) + .readdirSync(artifactFolder) .filter(isCmij) .map(basename => { - const bytes = fs.readFileSync(path.join(libOcamlFolder, basename)); + const bytes = fs.readFileSync(path.join(artifactFolder, basename)); return ` a("/static/${basename}", "${jsBytesLiteral(bytes)}");\n`; }); diff --git a/tests/build_tests/debug_ir/input.js b/tests/build_tests/debug_ir/input.js index b38e3d7352e..4e8e9af95ab 100644 --- a/tests/build_tests/debug_ir/input.js +++ b/tests/build_tests/debug_ir/input.js @@ -9,8 +9,7 @@ const { execBuildOrThrow, execClean } = setup(import.meta.dirname); const diagnosticsDir = path.join( import.meta.dirname, "lib", - "bs", - "src", + "rescript", "Main.debug-ir", ); diff --git a/tests/build_tests/post-build-out-of-source/input.js b/tests/build_tests/post-build-out-of-source/input.js index c5d3a8ee024..5b3ac89d8e8 100644 --- a/tests/build_tests/post-build-out-of-source/input.js +++ b/tests/build_tests/post-build-out-of-source/input.js @@ -32,15 +32,18 @@ try { // e.g., /path/to/post-build-out-of-source/lib/es6/src/demo.mjs (Unix) // e.g., C:\path\to\post-build-out-of-source\lib\es6\src\demo.mjs (Windows) const libEs6Sep = isWindows ? "\\lib\\es6\\" : "/lib/es6/"; - const libBsSep = isWindows ? "\\lib\\bs\\" : "/lib/bs/"; + const artifactSep = isWindows ? "\\lib\\rescript\\" : "/lib/rescript/"; for (const p of paths) { assert.ok( p.includes(libEs6Sep) && p.endsWith(".mjs"), `Path should be in lib/es6/ directory with .mjs suffix: ${p}`, ); - // Should NOT be in lib/bs/ when in-source is false - assert.ok(!p.includes(libBsSep), `Path should not be in lib/bs/: ${p}`); + // Should NOT be in lib/rescript/ when in-source is false + assert.ok( + !p.includes(artifactSep), + `Path should not be in lib/rescript/: ${p}`, + ); } } finally { // Clean up log file diff --git a/tests/build_tests/post-build/input.js b/tests/build_tests/post-build/input.js index 9c8d843c681..7469ec30da5 100644 --- a/tests/build_tests/post-build/input.js +++ b/tests/build_tests/post-build/input.js @@ -33,17 +33,17 @@ try { // e.g., /path/to/post-build/src/demo.js (Unix) // e.g., C:\path\to\post-build\src\demo.js (Windows) const srcSep = isWindows ? "\\src\\" : "/src/"; - const libBsSep = isWindows ? "\\lib\\bs\\" : "/lib/bs/"; + const artifactSep = isWindows ? "\\lib\\rescript\\" : "/lib/rescript/"; for (const p of paths) { assert.ok( p.includes(srcSep) && p.endsWith(".js"), `Path should be in src/ directory: ${p}`, ); - // Should NOT be in lib/bs/ when in-source is true + // Should NOT be in lib/rescript/ when in-source is true assert.ok( - !p.includes(libBsSep), - `Path should not be in lib/bs/ when in-source is true: ${p}`, + !p.includes(artifactSep), + `Path should not be in lib/rescript/ when in-source is true: ${p}`, ); } } finally { diff --git a/tests/build_tests/source_map/input.js b/tests/build_tests/source_map/input.js index 01a146923cb..ae19b9013a4 100644 --- a/tests/build_tests/source_map/input.js +++ b/tests/build_tests/source_map/input.js @@ -214,10 +214,6 @@ async function removeGeneratedMapFiles() { await fs.rm(path.join(import.meta.dirname, "src", `${filename}.map`), { force: true, }); - await fs.rm( - path.join(import.meta.dirname, "lib", "bs", "src", `${filename}.map`), - { force: true }, - ); } } @@ -382,7 +378,7 @@ async function assertLinkedOutput() { await execBuildOrThrow(); for (const filename of outputFilenames) { - const jsPath = path.join(import.meta.dirname, "lib", "bs", "src", filename); + const jsPath = path.join(import.meta.dirname, "src", filename); const mapPath = `${jsPath}.map`; const js = await fs.readFile(jsPath, "utf8"); @@ -416,7 +412,7 @@ async function assertNodeStackTraceUsesSourceMap() { await fs.writeFile( stackTraceScriptPath, ` - const Demo = require("./lib/bs/src/Demo.cjs"); + const Demo = require("./src/Demo.cjs"); Demo.unicodeCrash(); `, ); @@ -447,7 +443,7 @@ async function assertHiddenOutput() { await execBuildOrThrow(); for (const filename of outputFilenames) { - const jsPath = path.join(import.meta.dirname, "lib", "bs", "src", filename); + const jsPath = path.join(import.meta.dirname, "src", filename); const mapPath = `${jsPath}.map`; const js = await fs.readFile(jsPath, "utf8"); @@ -472,7 +468,7 @@ async function assertDefaultOutput() { const output = new Map(); for (const filename of outputFilenames) { - const jsPath = path.join(import.meta.dirname, "lib", "bs", "src", filename); + const jsPath = path.join(import.meta.dirname, "src", filename); const mapPath = `${jsPath}.map`; const js = await fs.readFile(jsPath, "utf8"); @@ -498,7 +494,7 @@ async function assertDisabledOutput(defaultOutput) { await execBuildOrThrow(); for (const filename of outputFilenames) { - const jsPath = path.join(import.meta.dirname, "lib", "bs", "src", filename); + const jsPath = path.join(import.meta.dirname, "src", filename); const mapPath = `${jsPath}.map`; const js = await fs.readFile(jsPath, "utf8"); @@ -528,7 +524,7 @@ async function assertInlineOutput() { await execBuildOrThrow(); for (const filename of outputFilenames) { - const jsPath = path.join(import.meta.dirname, "lib", "bs", "src", filename); + const jsPath = path.join(import.meta.dirname, "src", filename); const mapPath = `${jsPath}.map`; const js = await fs.readFile(jsPath, "utf8"); diff --git a/tests/build_tests/super_errors/input.js b/tests/build_tests/super_errors/input.js index d3ebf2b67d7..cf9ea806470 100644 --- a/tests/build_tests/super_errors/input.js +++ b/tests/build_tests/super_errors/input.js @@ -25,7 +25,7 @@ const beltLib = path.join( "@rescript", "belt", "lib", - "ocaml", + "rescript", ); const prefix = ["-w", "+A", "-bs-jsx", "4", "-I", beltLib]; diff --git a/tests/build_tests/unicode/input.js b/tests/build_tests/unicode/input.js index 65693376620..16ac21f717b 100644 --- a/tests/build_tests/unicode/input.js +++ b/tests/build_tests/unicode/input.js @@ -8,7 +8,5 @@ const { execBuildOrThrow, execClean } = setup(import.meta.dirname); await execBuildOrThrow(); -await fs.access( - path.join(import.meta.dirname, "lib", "bs", "src", "📕annotation", "a.js"), -); +await fs.access(path.join(import.meta.dirname, "src", "📕annotation", "a.js")); await execClean(); diff --git a/tests/package_tests/installation_test/packaged-cli-smoke.mjs b/tests/package_tests/installation_test/packaged-cli-smoke.mjs index 8f88533f96e..55f258030e1 100644 --- a/tests/package_tests/installation_test/packaged-cli-smoke.mjs +++ b/tests/package_tests/installation_test/packaged-cli-smoke.mjs @@ -6,7 +6,7 @@ import path from "node:path"; const launcher = path.resolve("node_modules/rescript/cli/rescript.js"); const output = path.resolve("src/Test.mjs"); -const watchLock = path.resolve("lib/watch.lock"); +const watchLock = path.resolve("lib/rescript/watch.lock"); const timeoutMs = process.platform === "win32" ? 120000 : 30000; function run(args, input) { diff --git a/tests/syntax_tests/res_test.ml b/tests/syntax_tests/res_test.ml index 4e84c9c0d13..3635debfdb9 100644 --- a/tests/syntax_tests/res_test.ml +++ b/tests/syntax_tests/res_test.ml @@ -659,8 +659,6 @@ module Outcome_printer_tests = struct let signature_to_outcome structure = Lazy.force Res_outcome_printer.setup; - (Clflags.current ()).include_dirs := - Filename.concat "lib" "ocaml" :: !((Clflags.current ()).include_dirs); Res_compmisc.init_path (); (Clflags.current ()).nopervasives := true; let env = Res_compmisc.initial_env () in