Skip to content

Commit 1b50793

Browse files
authored
Merge pull request #6623 from cknitt/11-to-master
2 parents 1284d58 + 30501f0 commit 1b50793

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+597
-196
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ jobs:
257257
env:
258258
KEYCDN_USER: ${{ secrets.KEYCDN_USER }}
259259
KEYCDN_PASSWORD: ${{ secrets.KEYCDN_PASSWORD }}
260-
run: sh playground/upload_bundle.sh
260+
run: bash playground/upload_bundle.sh
261261

262262
- name: Prepare artifact upload
263263
run: node .github/workflows/get_artifact_info.js

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,26 @@
1212
1313
# 12.0.0-alpha.1 (Unreleased)
1414

15-
# 11.1.0-rc.2 (Unreleased)
15+
#### :house: Internal
16+
17+
- Build with OCaml 5.1.0. https://github.com/rescript-lang/rescript-compiler/pull/5895
18+
19+
# 11.1.0-rc.2
20+
21+
#### :rocket: New Feature
22+
23+
- Add support for array spread. https://github.com/rescript-lang/rescript-compiler/pull/6608
24+
- Support import attributes (https://github.com/tc39/proposal-import-attributes) in `@module()`. https://github.com/rescript-lang/rescript-compiler/pull/6599
25+
- allow hyphens in jsx tag names (e.g. `<mj-column>`). https://github.com/rescript-lang/rescript-compiler/pull/6609
1626

1727
#### :bug: Bug Fix
1828

1929
- Fix issue with async and newtype in uncurried mode. https://github.com/rescript-lang/rescript-compiler/pull/6601
2030
- Generic JSX transform: Rename expected module name for lowercase JSX to `Elements` from `DOM`. https://github.com/rescript-lang/rescript-compiler/pull/6606
2131
- Generic JSX transform: Set default config params for `jsxConfig`. https://github.com/rescript-lang/rescript-compiler/pull/6606
2232
- Generic JSX transform: Handle namespaced names. https://github.com/rescript-lang/rescript-compiler/pull/6606
33+
- Fix issue with doc comment in recursive module. https://github.com/rescript-lang/rescript-compiler/pull/6613
34+
- Fix issue with Exceptions and Extensible types runtime generation. https://github.com/rescript-lang/rescript-compiler/pull/6570
2335

2436
#### :house: Internal
2537

jscomp/core/js_dump_import_export.ml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,24 +120,49 @@ let requires require_lit cxt f (modules : (Ident.t * string * bool) list) =
120120
P.newline f);
121121
outer_cxt
122122

123+
let dumpImportAttributes f (importAttributes : External_ffi_types.import_attributes option) =
124+
match importAttributes with
125+
| None -> ()
126+
| Some importAttributes ->
127+
P.space f;
128+
P.string f "with";
129+
P.space f;
130+
let total = Hashtbl.length importAttributes in
131+
let idx = ref 1 in
132+
P.brace_group f 0 (
133+
fun _ ->
134+
importAttributes |> Hashtbl.iter(fun key value ->
135+
Js_dump_string.pp_string f key;
136+
P.string f L.colon_space;
137+
Js_dump_string.pp_string f value;
138+
let shouldAddComma = !idx < total in
139+
if shouldAddComma then (
140+
P.string f L.comma;
141+
P.space f
142+
);
143+
idx := !idx + 1;
144+
)
145+
)
146+
123147
(** ES6 module style imports *)
124-
let imports cxt f (modules : (Ident.t * string * bool) list) =
148+
let imports cxt f (modules : (Ident.t * string * bool * External_ffi_types.import_attributes option) list) =
125149
(* the context used to print the following program *)
126150
let outer_cxt, reversed_list =
127-
Ext_list.fold_left modules (cxt, []) (fun (cxt, acc) (id, s, b) ->
151+
Ext_list.fold_left modules (cxt, []) (fun (cxt, acc) (id, s, b, i) ->
128152
let str, cxt = Ext_pp_scope.str_of_ident cxt id in
129-
(cxt, (str, s, b) :: acc))
153+
(cxt, (str, s, b, i) :: acc))
130154
in
131155
P.at_least_two_lines f;
132-
Ext_list.rev_iter reversed_list (fun (s, file, default) ->
156+
Ext_list.rev_iter reversed_list (fun (s, file, default, import_attributes) ->
133157
P.string f L.import;
134158
P.space f;
135159
if default then (
136160
P.string f s;
137161
P.space f;
138162
P.string f L.from;
139163
P.space f;
140-
Js_dump_string.pp_string f file)
164+
Js_dump_string.pp_string f file;
165+
dumpImportAttributes f import_attributes)
141166
else (
142167
P.string f L.star;
143168
P.space f;
@@ -148,7 +173,8 @@ let imports cxt f (modules : (Ident.t * string * bool) list) =
148173
P.space f;
149174
P.string f L.from;
150175
P.space f;
151-
Js_dump_string.pp_string f file);
176+
Js_dump_string.pp_string f file;
177+
dumpImportAttributes f import_attributes);
152178
P.string f L.semi;
153179
P.newline f);
154180
outer_cxt

jscomp/core/js_dump_import_export.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ val requires :
3636
Ext_pp_scope.t
3737

3838
val imports :
39-
Ext_pp_scope.t -> Ext_pp.t -> (Ident.t * string * bool) list -> Ext_pp_scope.t
39+
Ext_pp_scope.t -> Ext_pp.t -> (Ident.t * string * bool * External_ffi_types.import_attributes option) list -> Ext_pp_scope.t

jscomp/core/js_dump_program.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ let es6_program ~output_dir fmt f (x : J.deps_program) =
9494
| false ->
9595
Some ( x.id,
9696
Js_name_of_module_id.string_of_module_id x ~output_dir fmt,
97-
is_default x.kind )))
97+
is_default x.kind,
98+
(match x.kind with | External {import_attributes} -> import_attributes | _ -> None) )))
9899
in
99100
let () = P.at_least_two_lines f in
100101
let cxt = Js_dump.statements true cxt f x.program.block in

jscomp/core/js_exp_make.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,20 @@ let ml_var_dot ?comment ?(dynamic_import = false) (id : Ident.t) e : J.expressio
9292
var http = require("http")
9393
]}
9494
*)
95-
let external_var_field ?comment ~external_name:name (id : Ident.t) ~field
95+
let external_var_field ?import_attributes ?comment ~external_name:name (id : Ident.t) ~field
9696
~default : t =
9797
{
9898
expression_desc =
99-
Var (Qualified ({ id; kind = External { name; default }; dynamic_import = false }, Some field));
99+
Var (Qualified ({ id; kind = External { name; default; import_attributes }; dynamic_import = false }, Some field));
100100
comment;
101101
}
102102

103-
let external_var ?comment ~external_name (id : Ident.t) : t =
103+
let external_var ?import_attributes ?comment ~external_name (id : Ident.t) : t =
104104
{
105105
expression_desc =
106106
Var
107107
(Qualified
108-
( { id; kind = External { name = external_name; default = false }; dynamic_import = false },
108+
( { id; kind = External { name = external_name; default = false; import_attributes }; dynamic_import = false },
109109
None ));
110110
comment;
111111
}

jscomp/core/js_exp_make.mli

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ val ml_var_dot : ?comment:string -> ?dynamic_import:bool -> Ident.t -> string ->
5454
*)
5555

5656
val external_var_field :
57+
?import_attributes:External_ffi_types.import_attributes ->
5758
?comment:string ->
5859
external_name:string ->
5960
Ident.t ->
@@ -64,7 +65,7 @@ val external_var_field :
6465
Used in FFI
6566
*)
6667

67-
val external_var : ?comment:string -> external_name:string -> Ident.t -> t
68+
val external_var : ?import_attributes:External_ffi_types.import_attributes -> ?comment:string -> external_name:string -> Ident.t -> t
6869

6970
val ml_module_as_var : ?comment:string -> ?dynamic_import:bool -> Ident.t -> t
7071

jscomp/core/js_op.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ type int_op =
114114
*)
115115
type level = Log | Info | Warn | Error
116116

117-
type kind = Ml | Runtime | External of { name : string; default : bool }
117+
type kind = Ml | Runtime | External of { name : string; default : bool; import_attributes : External_ffi_types.import_attributes option }
118118

119119
type property = Lam_compat.let_kind = Strict | Alias | StrictOpt | Variable
120120

jscomp/core/lam_compile_env.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ let reset () =
5959
since when we print it in the end, it will
6060
be escaped quite ugly
6161
*)
62-
let add_js_module (hint_name : External_ffi_types.module_bind_name)
62+
let add_js_module ?import_attributes (hint_name : External_ffi_types.module_bind_name)
6363
(module_name : string) default : Ident.t =
6464
let id =
6565
Ident.create
@@ -71,7 +71,7 @@ let add_js_module (hint_name : External_ffi_types.module_bind_name)
7171
| Phint_nothing -> Ext_modulename.js_id_name_of_hint_name module_name)
7272
in
7373
let lam_module_ident : J.module_id =
74-
{ id; kind = External { name = module_name; default }; dynamic_import = false }
74+
{ id; kind = External { name = module_name; default; import_attributes }; dynamic_import = false }
7575
in
7676
match Lam_module_ident.Hash.find_key_opt cached_tbl lam_module_ident with
7777
| None ->

jscomp/core/lam_compile_env.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
val reset : unit -> unit
2828

2929
val add_js_module :
30-
External_ffi_types.module_bind_name -> string -> bool -> Ident.t
30+
?import_attributes:External_ffi_types.import_attributes -> External_ffi_types.module_bind_name -> string -> bool -> Ident.t
3131
(**
3232
[add_js_module hint_name module_name]
3333
Given a js module name and hint name, assign an id to it

jscomp/core/lam_compile_external_call.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ let splice_obj_apply obj name args =
5050
bundle *)
5151

5252
let external_var
53-
({ bundle; module_bind_name } : External_ffi_types.external_module_name) =
54-
let id = Lam_compile_env.add_js_module module_bind_name bundle false in
55-
E.external_var id ~external_name:bundle
53+
({ bundle; module_bind_name; import_attributes } : External_ffi_types.external_module_name) =
54+
let id = Lam_compile_env.add_js_module ?import_attributes module_bind_name bundle false in
55+
E.external_var ?import_attributes ~external_name:bundle id
5656

5757
(* let handle_external_opt
5858
(module_name : External_ffi_types.external_module_name option)
@@ -218,22 +218,22 @@ let translate_scoped_module_val
218218
(module_name : External_ffi_types.external_module_name option) (fn : string)
219219
(scopes : string list) =
220220
match module_name with
221-
| Some { bundle; module_bind_name } -> (
221+
| Some { bundle; module_bind_name; import_attributes } -> (
222222
match scopes with
223223
| [] ->
224224
let default = fn = "default" in
225225
let id =
226-
Lam_compile_env.add_js_module module_bind_name bundle default
226+
Lam_compile_env.add_js_module ?import_attributes module_bind_name bundle default
227227
in
228-
E.external_var_field ~external_name:bundle ~field:fn ~default id
228+
E.external_var_field ?import_attributes ~external_name:bundle ~field:fn ~default id
229229
| x :: rest ->
230230
(* TODO: what happens when scope contains "default" ?*)
231231
let default = false in
232232
let id =
233-
Lam_compile_env.add_js_module module_bind_name bundle default
233+
Lam_compile_env.add_js_module ?import_attributes module_bind_name bundle default
234234
in
235235
let start =
236-
E.external_var_field ~external_name:bundle ~field:x ~default id
236+
E.external_var_field ?import_attributes ~external_name:bundle ~field:x ~default id
237237
in
238238
Ext_list.fold_left (Ext_list.append rest [ fn ]) start E.dot)
239239
| None -> (

jscomp/core/lam_module_ident.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ module Cmp = struct
5252
type nonrec t = t
5353
let equal (x : t) y =
5454
match x.kind with
55-
| External {name = x_kind; default = x_default}->
55+
| External {name = x_kind; default = x_default; _} ->
5656
begin match y.kind with
57-
| External {name = y_kind; default = y_default} ->
57+
| External {name = y_kind; default = y_default; _} ->
5858
x_kind = (y_kind : string) && x_default = y_default
5959
| _ -> false
6060
end

0 commit comments

Comments
 (0)