Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#### :house: Internal

- Merge the duplicate Lam intermediate representation into Lambda, removing the conversion layer and obsolete supporting infrastructure. Lambda is now a single private, normalized representation, with generated JavaScript remaining semantically unchanged. https://github.com/rescript-lang/rescript/pull/8608
- Add genType and source map controls and output to the developer playground. https://github.com/rescript-lang/rescript/pull/8448
- Rework the object-type representation end to end: object rows are plain field chains carrying a per-field mutability state (no phantom setter members), object literals are typed directly and property access and assignment are first-class AST and Lambda nodes shared between the Lambda and JS pipelines, and dead class-system remnants (the field-presence lattice, the class-abbreviation memo on object types, method-send typing) are removed. https://github.com/rescript-lang/rescript/pull/8597
- Upgrade the development toolchain and primary CI builds to OCaml 5.5 while retaining OCaml 5.0 as the minimum supported version. https://github.com/rescript-lang/rescript/pull/8589
- Upgrade the vendored Flow parser from 0.267.0 to 0.320.0, the final release of the OCaml implementation. https://github.com/rescript-lang/rescript/pull/8588
Expand Down
16 changes: 12 additions & 4 deletions compiler/core/js_source_map.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type t = {
generated_dir: string;
source_root: string;
sources_content: bool;
provided_source_contents: (string, string) Hashtbl.t;
sources: (string, int) Hashtbl.t;
mutable source_list: source list;
mutable mappings: mapping list;
Expand Down Expand Up @@ -109,20 +110,27 @@ let relative_path ~from_dir ~to_file =
let parts = repeat ".." (List.length from_rest) @ to_rest in
if parts = [] then Filename.basename to_file else String.concat "/" parts

let make ~generated_file ~source_root ~sources_content =
let make ~source_contents ~generated_file ~source_root ~sources_content =
let provided_source_contents = Hashtbl.create (List.length source_contents) in
source_contents
|> List.iter (fun (filename, content) ->
Hashtbl.replace provided_source_contents (absolute_path filename) content);
{
generated_file = Filename.basename generated_file;
generated_dir = Filename.dirname generated_file;
source_root;
sources_content;
provided_source_contents;
sources = Hashtbl.create 4;
source_list = [];
mappings = [];
last_generated = None;
}

let load_content filename =
try Some (Ext_io.load_file filename) with _ -> None
let load_content builder filename =
match Hashtbl.find_opt builder.provided_source_contents filename with
| Some content -> Some content
| None -> ( try Some (Ext_io.load_file filename) with _ -> None)
Comment thread
fhammerschmidt marked this conversation as resolved.
Outdated

let add_source builder filename =
let filename =
Expand All @@ -138,7 +146,7 @@ let add_source builder filename =
{
relative_path =
relative_path ~from_dir:builder.generated_dir ~to_file:filename;
content = load_content filename;
content = load_content builder filename;
}
in
let index = List.length builder.source_list in
Expand Down
6 changes: 5 additions & 1 deletion compiler/core/js_source_map.mli
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
type t

val make :
generated_file:string -> source_root:string -> sources_content:bool -> t
source_contents:(string * string) list ->
generated_file:string ->
source_root:string ->
sources_content:bool ->
t

val with_builder : t -> (unit -> 'a) -> 'a

Expand Down
2 changes: 1 addition & 1 deletion compiler/core/lam_compile_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ let remove_stale_source_map ?(remove_stale_map = true) target_file =
let dump_deps_program_with_source_map ?(remove_stale_map = true) ~target_file
~output_prefix module_system lambda_output chan =
let builder =
Js_source_map.make ~generated_file:target_file
Js_source_map.make ~source_contents:[] ~generated_file:target_file
~source_root:!Js_config.source_map_root
~sources_content:!Js_config.source_map_sources_content
in
Expand Down
2 changes: 1 addition & 1 deletion compiler/jsoo/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
(= %{profile} browser))
(flags
(:standard -w +a-4-9-40-42-44-45))
(libraries core syntax ml js_of_ocaml))
(libraries core syntax ml gentype js_of_ocaml))
Loading
Loading