Skip to content

Commit ce0aa8d

Browse files
authored
Merge pull request rescript-lang#6728 from cknitt/11-to-master
Merge changes from 11.0_release into master
2 parents 2858ed7 + e33c17f commit ce0aa8d

Some content is hidden

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

59 files changed

+560
-107
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,25 @@
2727

2828
- Make the `--help` arg be prioritized in the CLI, so correctly prints help message and skip other commands. https://github.com/rescript-lang/rescript-compiler/pull/6667
2929

30+
# 11.1.0-rc.8
31+
32+
#### :rocket: New Feature
33+
34+
- Add `%todo` extension for leaving implementation for later. https://github.com/rescript-lang/rescript-compiler/pull/6713
35+
- Add `-warn-error` argument for generating errors in CI. Useful for `%todo` extension. https://github.com/rescript-lang/rescript-compiler/pull/6717
36+
37+
#### :bug: Bug Fix
38+
39+
- Improve error when using `@deriving(accessors)` on a variant with record arguments. https://github.com/rescript-lang/rescript-compiler/pull/6712
40+
- Stop escaping JSX prop names with hyphens. https://github.com/rescript-lang/rescript-compiler/pull/6705
41+
- Fix trailing undefined for optional parameters not omitted with `@send` and `@new`. https://github.com/rescript-lang/rescript-compiler/pull/6716
42+
- Fix JSX4 adding the incorrect type annotation for the prop `ref` in `React.forwardRef` component. https://github.com/rescript-lang/rescript-compiler/pull/6718
43+
- Fix description for warning number 110. https://github.com/rescript-lang/rescript-compiler/pull/6725
44+
45+
#### :nail_care: Polish
46+
47+
- Module spec `es6` and `es6-global` is deprecated in favor of `esmodule`. https://github.com/rescript-lang/rescript-compiler/pull/6709
48+
3049
# 11.1.0-rc.7
3150

3251
#### :bug: Bug Fix

docs/docson/build-schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"$schema": "http://json-schema.org/draft-04/schema#",
33
"definitions": {
44
"module-format": {
5-
"enum": ["commonjs", "es6", "es6-global"],
6-
"description": "es6-global generate relative `require` paths instead of relying on NodeJS' module resolution. Default: commonjs."
5+
"enum": ["esmodule", "commonjs", "es6", "es6-global"],
6+
"description": "es6 and es6-global are deprecated. Default: commonjs."
77
},
88
"suffix-spec": {
99
"type": "string",

jscomp/bsb/bsb_config.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,18 @@ let rev_lib_bs = ".." // ".."
4141

4242
(* access the js directory from "lib/bs",
4343
it would be '../js'
44+
45+
TODO: should be renamed, js -> cjs, es6 -> mjs in v12
4446
*)
4547
let lib_bs_prefix_of_format (x : Ext_module_system.t) =
4648
".."
47-
// match x with NodeJS -> "js" | Es6 -> "es6" | Es6_global -> "es6_global"
49+
// match x with Commonjs -> "js" | Esmodule -> "es6" | Es6_global -> "es6_global"
4850

4951
(* lib/js, lib/es6, lib/es6_global *)
5052
let top_prefix_of_format (x : Ext_module_system.t) =
5153
match x with
52-
| NodeJS -> lib_js
53-
| Es6 -> lib_es6
54+
| Commonjs -> lib_js
55+
| Esmodule -> lib_es6
5456
| Es6_global -> lib_es6_global
5557

5658
let rev_lib_bs_prefix p = rev_lib_bs // p

jscomp/bsb/bsb_config.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ val lib_js : string
3333
val lib_bs : string
3434

3535
val lib_es6 : string
36+
[@@ocaml.deprecated "will be removed in v12"]
3637

3738
val lib_es6_global : string
39+
[@@ocaml.deprecated "will be removed in v12"]
3840

3941
val lib_ocaml : string
4042

jscomp/bsb/bsb_ninja_regen.ml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ let ( // ) = Ext_path.combine
3030
return None if we dont need regenerate
3131
otherwise return Some info
3232
*)
33-
let regenerate_ninja ~(package_kind : Bsb_package_kind.t) ~forced ~per_proj_dir ~warn_legacy_config
33+
let regenerate_ninja ~(package_kind : Bsb_package_kind.t) ~forced ~per_proj_dir ~warn_legacy_config ~warn_as_error
3434
: Bsb_config_types.t option =
3535
let lib_artifacts_dir = Bsb_config.lib_bs in
3636
let lib_bs_dir = per_proj_dir // lib_artifacts_dir in
@@ -58,6 +58,23 @@ let regenerate_ninja ~(package_kind : Bsb_package_kind.t) ~forced ~per_proj_dir
5858
Bsb_config_parse.interpret_json
5959
~filename:config_filename ~json:config_json ~package_kind ~per_proj_dir
6060
in
61+
62+
let warning = match config.warning with
63+
| None -> (
64+
match warn_as_error with
65+
| Some e -> Some {Bsb_warning.number = Some e; error = Warn_error_number e}
66+
| None -> None)
67+
| Some {error} as t ->
68+
match (warn_as_error, error) with
69+
| (Some error_str, Warn_error_false) ->
70+
Some {number = Some error_str; error = Warn_error_number error_str}
71+
| (Some error_str, Warn_error_number prev) ->
72+
let new_error = prev ^ error_str in
73+
Some {number = Some new_error; error = Warn_error_number new_error}
74+
| _ -> t
75+
in
76+
77+
let config = {config with warning = warning} in
6178
(* create directory, lib/bs, lib/js, lib/es6 etc *)
6279
Bsb_build_util.mkp lib_bs_dir;
6380
Bsb_package_specs.list_dirs_by config.package_specs (fun x ->

jscomp/bsb/bsb_ninja_regen.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ val regenerate_ninja :
2727
forced:bool ->
2828
per_proj_dir:string ->
2929
warn_legacy_config:bool ->
30+
warn_as_error:string option ->
3031
Bsb_config_types.t option
3132
(** Regenerate ninja file by need based on [.bsdeps]
3233
return None if we dont need regenerate

jscomp/bsb/bsb_package_specs.ml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,29 @@ let ( .?() ) = Map_string.find_opt
4040
let bad_module_format_message_exn ~loc format =
4141
Bsb_exception.errorf ~loc
4242
"package-specs: `%s` isn't a valid output module format. It has to be one \
43-
of: %s, %s or %s"
44-
format Literals.commonjs Literals.es6 Literals.es6_global
43+
of: %s or %s"
44+
format Literals.esmodule Literals.commonjs
4545

4646
let supported_format (x : string) loc : Ext_module_system.t =
47-
if x = Literals.commonjs then NodeJS
48-
else if x = Literals.es6 then Es6
47+
let _ =
48+
if x = Literals.es6 || x = Literals.es6_global then
49+
let loc_end =
50+
{loc with Lexing.pos_cnum = loc.Lexing.pos_cnum + String.length x}
51+
in
52+
let loc = {Warnings.loc_start = loc; loc_end; loc_ghost = false} in
53+
Location.deprecated loc
54+
(Printf.sprintf "Option \"%s\" is deprecated. Use \"%s\" instead." x
55+
Literals.esmodule)
56+
in
57+
if x = Literals.es6 || x = Literals.esmodule then Esmodule
58+
else if x = Literals.commonjs then Commonjs
4959
else if x = Literals.es6_global then Es6_global
5060
else bad_module_format_message_exn ~loc x
5161

5262
let string_of_format (x : Ext_module_system.t) =
5363
match x with
54-
| NodeJS -> Literals.commonjs
55-
| Es6 -> Literals.es6
64+
| Commonjs -> Literals.commonjs
65+
| Esmodule -> Literals.esmodule
5666
| Es6_global -> Literals.es6_global
5767

5868
let js_suffix_regexp = Str.regexp "[A-Za-z0-9-_.]*\\.[cm]?js"
@@ -158,7 +168,8 @@ let package_flag_of_package_specs (package_specs : t) ~(dirname : string) :
158168
| Some x -> Ext_string.inter3 res "-runtime" x
159169

160170
let default_package_specs suffix =
161-
Spec_set.singleton { format = NodeJS; in_source = false; suffix }
171+
(* TODO: swap default to Esmodule in v12 *)
172+
Spec_set.singleton { format = Commonjs; in_source = false; suffix }
162173

163174
(**
164175
[get_list_of_output_js specs "src/hi/hello"]

jscomp/bsb/bsb_spec_set.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
[@@@warning "+9"]
2626

2727
(* TODO: sync up with {!Js_packages_info.module_system} *)
28-
type format = Ext_module_system.t = NodeJS | Es6 | Es6_global
28+
type format = Ext_module_system.t
2929

3030
type spec = { format : format; in_source : bool; suffix : string }
3131

jscomp/bsb/bsb_warning.mli

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,16 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

25-
type t
25+
type warning_error =
26+
| Warn_error_false
27+
(* default [false] to make our changes non-intrusive *)
28+
| Warn_error_true
29+
| Warn_error_number of string
30+
31+
type t0 = { number : string option; error : warning_error }
32+
33+
type nonrec t = t0 option
34+
2635

2736
val to_merlin_string : t -> string
2837
(** Extra work is need to make merlin happy *)

jscomp/bsb/bsb_world.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ let ( // ) = Ext_path.combine
2626
let vendor_ninja = Bsb_global_paths.vendor_ninja
2727

2828
let make_world_deps cwd (config : Bsb_config_types.t option)
29-
(ninja_args : string array) =
29+
(ninja_args : string array) warn_as_error =
3030
let package_specs, jsx, uncurried, pinned_dependencies =
3131
match config with
3232
| None ->
@@ -71,6 +71,7 @@ let make_world_deps cwd (config : Bsb_config_types.t option)
7171
else Dependency { package_specs; jsx; uncurried })
7272
~per_proj_dir:proj_dir ~forced:false
7373
~warn_legacy_config:false
74+
~warn_as_error:(if is_pinned then warn_as_error else None)
7475
in
7576
let command =
7677
{ Bsb_unix.cmd = vendor_ninja; cwd = lib_bs_dir; args }

0 commit comments

Comments
 (0)