Skip to content

Commit a7ff3f9

Browse files
committed
Merge branch 'master' into throw-error-instance
2 parents c4f1f7c + 8403cdb commit a7ff3f9

File tree

1,126 files changed

+58198
-48936
lines changed

Some content is hidden

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

1,126 files changed

+58198
-48936
lines changed

.github/workflows/ci.yml

Lines changed: 90 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,67 @@ env:
2020
OCAMLRUNPARAM: b
2121

2222
jobs:
23+
build-rewatch:
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
os: [
28+
macos-13, # x64
29+
macos-14, # ARM
30+
ubuntu-latest, # x64
31+
buildjet-2vcpu-ubuntu-2204-arm, # ARM
32+
windows-latest,
33+
]
34+
include:
35+
- os: macos-13
36+
rust-target: x86_64-apple-darwin
37+
- os: macos-14
38+
rust-target: aarch64-apple-darwin
39+
- os: ubuntu-latest
40+
rust-target: x86_64-unknown-linux-musl
41+
- os: buildjet-2vcpu-ubuntu-2204-arm
42+
rust-target: aarch64-unknown-linux-musl
43+
- os: windows-latest
44+
rust-target: x86_64-pc-windows-gnu
45+
46+
runs-on: ${{matrix.os}}
47+
48+
env:
49+
RUST_BACKTRACE: "1"
50+
SCCACHE_GHA_ENABLED: "true"
51+
RUSTC_WRAPPER: "sccache"
52+
53+
steps:
54+
- name: Checkout
55+
uses: actions/checkout@v4
56+
57+
- name: Install musl gcc
58+
if: runner.os == 'Linux'
59+
run: sudo apt-get install -y musl-tools
60+
61+
- name: Set up sccache
62+
uses: mozilla-actions/sccache-action@v0.0.4
63+
with:
64+
version: "v0.8.0"
65+
66+
- name: Install rust toolchain
67+
uses: dtolnay/rust-toolchain@master
68+
with:
69+
toolchain: stable
70+
targets: ${{matrix.rust-target}}
71+
72+
- name: Build rewatch
73+
run: cargo build --manifest-path rewatch/Cargo.toml --target ${{matrix.rust-target}} --release
74+
75+
- name: Get artifact dir name
76+
run: node .github/workflows/get_artifact_dir_name.js
77+
78+
- name: "Upload artifact: rewatch binary"
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: rewatch-${{env.artifact_dir_name}}
82+
path: rewatch/target/${{matrix.rust-target}}/release/rewatch${{ runner.os == 'Windows' && '.exe' || '' }}
83+
2384
# Build statically linked Linux binaries in an Alpine-based Docker container
2485
# See https://ocamlpro.com/blog/2021_09_02_generating_static_and_portable_executables_with_ocaml
2586
# for more info.
@@ -59,6 +120,7 @@ jobs:
59120
# Therefore, only upload the binaries from the static build
60121
upload-linux-arm64-binaries:
61122
needs:
123+
- build-rewatch
62124
- static-binaries-linux
63125

64126
runs-on: buildjet-2vcpu-ubuntu-2204-arm
@@ -73,31 +135,33 @@ jobs:
73135
with:
74136
name: static-binaries-linux-${{ runner.arch }}
75137

76-
- name: Make static linux binaries executable
77-
if: runner.os == 'Linux'
78-
run: |
79-
chmod +x ninja/ninja
80-
chmod +x _build/install/default/bin/*
81-
82138
- name: Use Node.js
83139
uses: actions/setup-node@v4
84140
with:
85141
node-version: 18
86142

143+
- name: Get artifact dir name
144+
run: node .github/workflows/get_artifact_dir_name.js
145+
146+
- name: Download rewatch binary
147+
uses: actions/download-artifact@v4
148+
with:
149+
name: rewatch-${{ env.artifact_dir_name }}
150+
path: rewatch
151+
87152
- name: Copy exes to platform bin dirs
88153
run: node ./scripts/copyExes.js
89154

90-
- name: Prepare artifact upload
91-
run: node .github/workflows/get_artifact_info.js
92-
93155
- name: "Upload artifacts: binaries"
94156
uses: actions/upload-artifact@v4
95157
with:
96-
name: ${{ env.artifact_name }}
97-
path: ${{ env.artifact_path }}
158+
name: binaries-${{ env.artifact_dir_name }}
159+
path: ${{ env.artifact_dir_name }}
98160

99161
build:
100-
needs: static-binaries-linux
162+
needs:
163+
- build-rewatch
164+
- static-binaries-linux
101165

102166
strategy:
103167
fail-fast: false
@@ -133,10 +197,20 @@ jobs:
133197
with:
134198
name: static-binaries-linux-${{ runner.arch }}
135199

200+
- name: Get artifact dir name
201+
run: node .github/workflows/get_artifact_dir_name.js
202+
203+
- name: Download rewatch binary
204+
uses: actions/download-artifact@v4
205+
with:
206+
name: rewatch-${{ env.artifact_dir_name }}
207+
path: rewatch
208+
136209
- name: Make static linux binaries executable
137210
if: runner.os == 'Linux'
138211
run: |
139212
chmod +x ninja/ninja
213+
chmod +x rewatch/rewatch
140214
chmod +x _build/install/default/bin/*
141215
142216
- name: Use OCaml ${{matrix.ocaml_compiler}}
@@ -252,14 +326,11 @@ jobs:
252326
KEYCDN_PASSWORD: ${{ secrets.KEYCDN_PASSWORD }}
253327
run: bash playground/upload_bundle.sh
254328

255-
- name: Prepare artifact upload
256-
run: node .github/workflows/get_artifact_info.js
257-
258329
- name: "Upload artifacts: binaries"
259330
uses: actions/upload-artifact@v4
260331
with:
261-
name: ${{ env.artifact_name }}
262-
path: ${{ env.artifact_path }}
332+
name: binaries-${{ env.artifact_dir_name }}
333+
path: ${{ env.artifact_dir_name }}
263334

264335
- name: "Upload artifacts: lib/ocaml"
265336
if: runner.os == 'Linux'
@@ -286,6 +357,8 @@ jobs:
286357

287358
- name: Download artifacts
288359
uses: actions/download-artifact@v4
360+
with:
361+
pattern: "@(binaries-*|lib-ocaml)"
289362

290363
- name: Move artifacts
291364
run: ./scripts/moveArtifacts.sh
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const fs = require("fs");
2+
const os = require("os");
3+
4+
const artifactDirName = require("../../scripts/bin_path").dirName;
5+
6+
// Pass artifactDirName to subsequent GitHub actions
7+
fs.appendFileSync(
8+
process.env.GITHUB_ENV,
9+
`artifact_dir_name=${artifactDirName}${os.EOL}`
10+
);

.github/workflows/get_artifact_info.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,86 @@
1212
1313
# 12.0.0-alpha.1 (Unreleased)
1414

15+
#### :rocket: New Feature
16+
17+
- Allow `@directive` on functions for emitting function level directive code (`let serverAction = @directive("'use server'") (~name) => {...}`). https://github.com/rescript-lang/rescript-compiler/pull/6756
18+
- Add `rewatch` to the npm package as an alternative build tool. https://github.com/rescript-lang/rescript-compiler/pull/6762
19+
1520
#### :boom: Breaking Change
1621

1722
- `lazy` syntax is no longer supported. If you're using it, use `Lazy` module or `React.lazy_` instead. https://github.com/rescript-lang/rescript-compiler/pull/6342
1823
- Remove handling of attributes with `bs.` prefix (`@bs.as` -> `@as` etc.). https://github.com/rescript-lang/rescript-compiler/pull/6643
1924
- Remove obsolete `@bs.open` feature. https://github.com/rescript-lang/rescript-compiler/pull/6629
2025
- Drop Node.js version <18 support, due to it reaching End-of-Life. https://github.com/rescript-lang/rescript-compiler/pull/6429
2126

27+
#### :bug: Bug Fix
28+
29+
- Fix unhandled cases for exotic idents (allow to use exotic PascalCased identifiers for types). https://github.com/rescript-lang/rescript-compiler/pull/6777
30+
- Fix issue of incorrect switch cases with identical bodies when mixing object and array. https://github.com/rescript-lang/rescript-compiler/pull/6792
31+
- Fix formatter eats comments on the first argument of an uncurried function. https://github.com/rescript-lang/rescript-compiler/pull/6763
32+
- Fix formatter removes parens in pipe operator with anonymous uncurried function. https://github.com/rescript-lang/rescript-compiler/pull/6766
33+
2234
#### :house: Internal
2335

2436
- Build with OCaml 5.1.1. https://github.com/rescript-lang/rescript-compiler/pull/6641
37+
- Convert OCaml codebase to snake case style. https://github.com/rescript-lang/rescript-compiler/pull/6702
38+
- Fix location of let bindings with attributes. https://github.com/rescript-lang/rescript-compiler/pull/6791
39+
- Refactor uppercase exotic ident handling. https://github.com/rescript-lang/rescript-compiler/pull/6779
2540

2641
#### :nail_care: Polish
2742

2843
- 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
44+
- Remove redundant space for empty return in generated js code. https://github.com/rescript-lang/rescript-compiler/pull/6745
45+
- Remove redundant space for export in generated js code. https://github.com/rescript-lang/rescript-compiler/pull/6560
46+
- Remove redundant space after continue in generated js code. https://github.com/rescript-lang/rescript-compiler/pull/6743
47+
- Remove empty export blocks in generated js code. https://github.com/rescript-lang/rescript-compiler/pull/6744
48+
- Fix indent for returned/thrown/wrapped in parentheses objects in generated js code. https://github.com/rescript-lang/rescript-compiler/pull/6746
49+
- Fix indent in generated js code. https://github.com/rescript-lang/rescript-compiler/pull/6747
50+
- In generated code, use `let` instead of `var`. https://github.com/rescript-lang/rescript-compiler/pull/6102
51+
- Turn off transformation for closures inside loops when capturing loop variables, now that `let` is emitted instead of `var`. https://github.com/rescript-lang/rescript-compiler/pull/6480
52+
- Improve unused attribute warning message. https://github.com/rescript-lang/rescript-compiler/pull/6787
53+
- Remove unused -no-stdlib compiler option. https://github.com/rescript-lang/rescript-compiler/pull/6778
54+
55+
# 11.1.0
56+
57+
#### :bug: Bug Fix
58+
59+
- Revert escape JSX prop names with hyphens (#6705). https://github.com/rescript-lang/rescript-compiler/pull/6731
60+
61+
# 11.1.0-rc.8
62+
63+
#### :rocket: New Feature
64+
65+
- Add `%todo` extension for leaving implementation for later. https://github.com/rescript-lang/rescript-compiler/pull/6713
66+
- Add `-warn-error` argument for generating errors in CI. Useful for `%todo` extension. https://github.com/rescript-lang/rescript-compiler/pull/6717
67+
68+
#### :bug: Bug Fix
69+
70+
- Improve error when using `@deriving(accessors)` on a variant with record arguments. https://github.com/rescript-lang/rescript-compiler/pull/6712
71+
- Stop escaping JSX prop names with hyphens. https://github.com/rescript-lang/rescript-compiler/pull/6705
72+
- Fix trailing undefined for optional parameters not omitted with `@send` and `@new`. https://github.com/rescript-lang/rescript-compiler/pull/6716
73+
- Fix JSX4 adding the incorrect type annotation for the prop `ref` in `React.forwardRef` component. https://github.com/rescript-lang/rescript-compiler/pull/6718
74+
- Fix description for warning number 110. https://github.com/rescript-lang/rescript-compiler/pull/6725
75+
76+
#### :nail_care: Polish
77+
78+
- Module spec `es6` and `es6-global` is deprecated in favor of `esmodule`. https://github.com/rescript-lang/rescript-compiler/pull/6709
79+
80+
# 11.1.0-rc.7
81+
82+
#### :bug: Bug Fix
83+
84+
- Fix variance setting for builtin `dict` type. Fixes issues around inference. https://github.com/rescript-lang/rescript-compiler/pull/6707
85+
86+
# 11.1.0-rc.6
87+
88+
#### :rocket: New Feature
89+
90+
- Add experimental BigInt support. https://github.com/rescript-lang/rescript-compiler/pull/6670, https://github.com/rescript-lang/rescript-compiler/pull/6696
91+
92+
#### :bug: Bug Fix
93+
94+
- Fix mishandling of uncurried functions in super errors. https://github.com/rescript-lang/rescript-compiler/pull/6694
2995

3096
# 11.1.0-rc.5
3197

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Happy hacking!
1616
1717
- [NodeJS v18](https://nodejs.org/)
1818
- C compiler toolchain (usually installed with `xcode` on Mac)
19+
- Rust toolchain (required to build rewatch; follow the instructions at https://www.rust-lang.org/tools/install)
1920
- `opam` (OCaml Package Manager)
2021
- VSCode (+ [OCaml Platform Extension](https://marketplace.visualstudio.com/items?itemName=ocamllabs.ocaml-platform))
2122

@@ -91,6 +92,11 @@ make test-syntax-roundtrip
9192
make artifacts
9293
```
9394

95+
## Coding Style
96+
97+
- OCaml Code: snake case format is used, e.g, `to_string`
98+
- ReScript Code: the camel case format is used, e.g `toString`
99+
94100
## Adding new Files to the Npm Package
95101

96102
To make sure that no files are added to or removed from the npm package inadvertently, an artifact list is kept at `packages/artifacts.txt`. During CI build, it is verified that only the files that are listed there are actually included in the npm package.

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL = /bin/bash
22

33
DUNE_BIN_DIR = ./_build/install/default/bin
44

5-
build: ninja
5+
build: ninja rewatch
66
dune build
77
./scripts/copyExes.js
88

@@ -15,6 +15,10 @@ bench:
1515
dce:
1616
reanalyze.exe -dce-cmt _build/default/jscomp
1717

18+
rewatch:
19+
cargo build --manifest-path rewatch/Cargo.toml
20+
cp rewatch/target/debug/rewatch rewatch
21+
1822
ninja/ninja:
1923
./scripts/buildNinjaBinary.js
2024

@@ -78,10 +82,11 @@ clean-gentype:
7882

7983
clean:
8084
dune clean
81-
./scripts/ninja.js clean
85+
cargo clean --manifest-path rewatch/Cargo.toml && rm -f rewatch/rewatch
86+
./scripts/ninja.js clean && rm -f ninja/ninja
8287

8388
clean-all: clean clean-gentype
8489

8590
.DEFAULT_GOAL := build
8691

87-
.PHONY: build watch ninja bench dce test test-syntax test-syntax-roundtrip test-gentype test-all lib playground playground-cmijs playground-release artifacts format checkformat clean-gentype clean clean-all
92+
.PHONY: build watch rewatch ninja bench dce test test-syntax test-syntax-roundtrip test-gentype test-all lib playground playground-cmijs playground-release artifacts format checkformat clean-gentype clean clean-all

docs/docson/build-schema.json

Lines changed: 2 additions & 6 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",
@@ -472,10 +472,6 @@
472472
"$ref": "#/definitions/package-specs",
473473
"description": "ReScript can currently output to [Commonjs](https://en.wikipedia.org/wiki/CommonJS), and [ES6 modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import)"
474474
},
475-
"use-stdlib": {
476-
"type": "boolean",
477-
"description": "(Experimental) whether to use the OCaml standard library. Default: true"
478-
},
479475
"external-stdlib": {
480476
"type": "string",
481477
"description": "Use the external stdlib library instead of the one shipped with the compiler package"

jscomp/bsb/bsb_build_schemas.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ let package_specs = "package-specs"
4545
let type_ = "type"
4646
let export_all = "all"
4747
let export_none = "none"
48-
let use_stdlib = "use-stdlib"
4948
let external_stdlib = "external-stdlib"
5049
let reason = "reason"
5150
let react_jsx = "react-jsx"

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

0 commit comments

Comments
 (0)