Skip to content

Commit 66d5fdf

Browse files
committed
Merge branch 'master' into group-jsx-modules
2 parents 668ccb3 + 72d534a commit 66d5fdf

File tree

423 files changed

+6486
-38737
lines changed

Some content is hidden

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

423 files changed

+6486
-38737
lines changed

.github/workflows/ci.yml

Lines changed: 61 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ jobs:
4545
- name: Checkout
4646
uses: actions/checkout@v4
4747

48+
- name: Use Node.js
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version-file: .nvmrc
52+
4853
- name: Restore build cache
4954
id: build-cache
5055
uses: actions/cache@v4
@@ -123,11 +128,12 @@ jobs:
123128
DUNE_PROFILE: release
124129

125130
steps:
126-
- name: "Windows: Set git to use LF"
131+
- name: "Windows: Set git config"
127132
if: runner.os == 'Windows'
128133
run: |
129-
git config --global core.autocrlf false
130-
git config --global core.eol lf
134+
git config --system core.autocrlf false
135+
git config --system core.eol lf
136+
git config --system core.longpaths true
131137
132138
- name: Checkout
133139
uses: actions/checkout@v4
@@ -152,7 +158,7 @@ jobs:
152158
# matrix.ocaml_compiler may contain commas
153159
- name: Get OPAM cache key
154160
shell: bash
155-
run: echo "opam_cache_key=opam-env-v7-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('dune-project') }}" | sed 's/,/-/g' >> $GITHUB_ENV
161+
run: echo "opam_cache_key=opam-env-v7-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('*.opam') }}" | sed 's/,/-/g' >> $GITHUB_ENV
156162

157163
- name: Restore OPAM environment
158164
id: cache-opam-env
@@ -249,7 +255,7 @@ jobs:
249255
id: compiler-build-state-key
250256
shell: bash
251257
run: |
252-
echo "value=compiler-build-state-v1-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('dune-project') }}" \
258+
echo "value=compiler-build-state-v1-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('*.opam') }}" \
253259
| sed 's/,/-/g' >> "$GITHUB_OUTPUT"
254260
255261
- name: Restore compiler build state
@@ -368,51 +374,50 @@ jobs:
368374
if: matrix.benchmarks
369375
run: ./_build/install/default/bin/syntax_benchmarks | tee tests/benchmark-output.json
370376

371-
- name: Restore previous benchmark data
372-
if: matrix.benchmarks
373-
uses: actions/cache/restore@v4
374-
with:
375-
path: ./tests/benchmark-cache
376-
key: syntax-benchmark-v1
377-
378-
- name: Create new benchmark data and comment on alert
379-
# Do not run for PRs created from other repos as those won't be able to write to the pull request
380-
if: ${{ matrix.benchmarks && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.repository.full_name) }}
381-
uses: benchmark-action/github-action-benchmark@v1
382-
with:
383-
name: Syntax Benchmarks
384-
tool: customSmallerIsBetter
385-
output-file-path: tests/benchmark-output.json
386-
external-data-json-path: ./tests/benchmark-cache/benchmark-data.json
387-
github-token: ${{ secrets.GITHUB_TOKEN }}
388-
alert-threshold: "105%"
389-
comment-always: false
390-
comment-on-alert: true
391-
392-
- name: Save benchmark data as new baseline
393-
if: matrix.benchmarks && github.ref == 'refs/heads/master'
394-
uses: actions/cache/save@v4
395-
with:
396-
path: ./tests/benchmark-cache
397-
key: syntax-benchmark-v1
377+
# Benchmarking is disabled for now because of inconsistent run times on different runners
378+
#
379+
# - name: Restore previous benchmark data
380+
# if: matrix.benchmarks
381+
# uses: actions/cache/restore@v4
382+
# with:
383+
# path: ./tests/benchmark-cache
384+
# key: syntax-benchmark-v1
385+
386+
# - name: Create new benchmark data and comment on alert
387+
# # Do not run for PRs created from other repos as those won't be able to write to the pull request
388+
# if: ${{ matrix.benchmarks && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.repository.full_name) }}
389+
# uses: benchmark-action/github-action-benchmark@v1
390+
# with:
391+
# name: Syntax Benchmarks
392+
# tool: customSmallerIsBetter
393+
# output-file-path: tests/benchmark-output.json
394+
# external-data-json-path: ./tests/benchmark-cache/benchmark-data.json
395+
# github-token: ${{ secrets.GITHUB_TOKEN }}
396+
# alert-threshold: "105%"
397+
# comment-always: false
398+
# comment-on-alert: true
399+
400+
# - name: Save benchmark data as new baseline
401+
# if: matrix.benchmarks && github.ref == 'refs/heads/master'
402+
# uses: actions/cache/save@v4
403+
# with:
404+
# path: ./tests/benchmark-cache
405+
# key: syntax-benchmark-v1
398406

399407
- name: Build playground compiler
400408
if: matrix.build_playground
401-
run: |
402-
opam exec -- node packages/playground-bundling/scripts/generate_cmijs.js
403-
opam exec -- dune build --profile browser
404-
cp ./_build/default/compiler/jsoo/jsoo_playground_main.bc.js playground/compiler.js
409+
run: opam exec -- make playground playground-cmijs
405410

406411
- name: Test playground compiler
407412
if: matrix.build_playground
408-
run: node playground/playground_test.js
413+
run: yarn workspace playground test
409414

410415
- name: Upload playground compiler to CDN
411416
if: ${{ matrix.build_playground && startsWith(github.ref, 'refs/tags/v') }}
412417
env:
413418
KEYCDN_USER: ${{ secrets.KEYCDN_USER }}
414419
KEYCDN_PASSWORD: ${{ secrets.KEYCDN_PASSWORD }}
415-
run: bash playground/upload_bundle.sh
420+
run: yarn workspace playground upload-bundle
416421

417422
- name: "Upload artifacts: binaries"
418423
if: matrix.upload_binaries
@@ -505,23 +510,36 @@ jobs:
505510
with:
506511
node-version-file: .nvmrc
507512

513+
- name: Make test directory
514+
id: tmp-dir
515+
shell: bash
516+
run: |
517+
if [[ "$RUNNER_OS" == "Windows" ]]; then
518+
dir=$(powershell -Command "[System.IO.Path]::GetTempPath() + [System.Guid]::NewGuid().ToString()" | tr -d '\r')
519+
mkdir -p "$dir"
520+
else
521+
dir=$(mktemp -d)
522+
fi
523+
echo "path=$dir" >> "$GITHUB_OUTPUT"
524+
cp -r tests/package_tests/installation_test/* "$dir"
525+
508526
- name: Download artifacts
509527
uses: actions/download-artifact@v4
510528
with:
511529
name: npm-packages
512-
path: packages/test
530+
path: ${{ steps.tmp-dir.outputs.path }}
513531

514532
- name: Install ReScript package
515533
run: |
516534
npm i --ignore-scripts --no-audit \
517535
rescript-${{ needs.package.outputs.rescript_version }}.tgz
518536
shell: bash
519-
working-directory: packages/test
537+
working-directory: ${{ steps.tmp-dir.outputs.path }}
520538

521539
- name: Test installation
522-
run: npx rescript -h && npx rescript build && cat src/Test.bs.js
540+
run: npx rescript -h && npx rescript build && cat src/Test.res.js
523541
shell: bash
524-
working-directory: packages/test
542+
working-directory: ${{ steps.tmp-dir.outputs.path }}
525543

526544
publish:
527545
needs: [package, installationTest]
@@ -556,5 +574,5 @@ jobs:
556574
- name: Update Website Playground
557575
env:
558576
NEXT_REVALIDATE_SECRET_TOKEN: ${{ secrets.NEXT_REVALIDATE_SECRET_TOKEN }}
559-
run: ./playground/website_update_playground.sh
577+
run: yarn workspace playground revalidate
560578
shell: bash
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const fs = require("fs");
2-
const os = require("os");
1+
import * as fs from "node:fs";
2+
import * as os from "node:os";
33

4-
const { dirName: artifactDirName } = require("../../cli/bin_path.js");
4+
import { platformName } from "#cli/bins";
55

66
// Pass artifactDirName to subsequent GitHub actions
77
fs.appendFileSync(
88
process.env.GITHUB_ENV,
9-
`artifact_dir_name=${artifactDirName}${os.EOL}`,
9+
`artifact_dir_name=${platformName}${os.EOL}`,
1010
);

.github/workflows/prepare_package_upload.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
const fs = require("fs");
2-
const os = require("os");
1+
import * as fs from "node:fs";
2+
import * as os from "node:os";
3+
4+
const packageSpec = JSON.parse(
5+
fs.readFileSync(new URL("../../package.json", import.meta.url), "utf-8")
6+
);
37

4-
const packageSpec = require("rescript/package.json");
58
const { version } = packageSpec;
69

710
const commitHash = process.argv[2] || process.env.GITHUB_SHA;

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ playground/stdlib/
7272
playground/*.cmj
7373
playground/*.cmi
7474
playground/.netrc
75-
playground/compiler.js
75+
playground/compiler.*js
7676

7777
rewatch/target/
7878
rewatch/rewatch
@@ -88,3 +88,5 @@ tests/analysis_tests/**/*.bs.js
8888
!.yarn/releases
8989
!.yarn/sdks
9090
!.yarn/versions
91+
92+
*.tsbuildinfo

.yarnrc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ yarnPath: .yarn/releases/yarn-4.7.0.cjs
33
nodeLinker: node-modules
44

55
nmMode: hardlinks-global
6+
7+
defaultSemverRangePrefix: ""

CHANGELOG.md

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,72 @@
1010
> - :house: [Internal]
1111
> - :nail_care: [Polish]
1212
13-
# 12.0.0-alpha.10 (Unreleased)
13+
# 12.0.0-alpha.13 (Unreleased)
14+
15+
#### :rocket: New Feature
16+
17+
- Add shift (`<<`, `>>`, `>>>`) operators for `int` and `bigint`. https://github.com/rescript-lang/rescript/pull/7183
18+
19+
#### :bug: Bug fix
20+
21+
- Fix broken `bstracing` CLI location. https://github.com/rescript-lang/rescript/pull/7398
22+
23+
# 12.0.0-alpha.12
24+
25+
#### :bug: Bug fix
26+
27+
- Fix node.js `ExperimentalWarning`. https://github.com/rescript-lang/rescript/pull/7379
28+
- Fix issue with gentype and stdlib json. https://github.com/rescript-lang/rescript/pull/7378
29+
- Fix type of `RegExp.Result.matches`. https://github.com/rescript-lang/rescript/pull/7393
30+
- Add optional `flags` argument to `RegExp.fromString` and deprecate `RegExp.fromStringWithFlags`. https://github.com/rescript-lang/rescript/pull/7393
31+
32+
#### :house: Internal
33+
34+
- Better representation of JSX in AST. https://github.com/rescript-lang/rescript/pull/7286
35+
36+
#### :nail_care: Polish
37+
38+
- Improve error message for missing value when the identifier is also the name of a module in scope. https://github.com/rescript-lang/rescript/pull/7384
39+
- Upgrade Flow parser to 0.267.0. https://github.com/rescript-lang/rescript/pull/7390
40+
41+
# 12.0.0-alpha.11
42+
43+
#### :bug: Bug fix
44+
45+
- Fix `Error.fromException`. https://github.com/rescript-lang/rescript/pull/7364
46+
- Fix signature of `throw`. https://github.com/rescript-lang/rescript/pull/7365
47+
- Fix formatter adds superfluous parens in pipe chain. https://github.com/rescript-lang/rescript/pull/7370
48+
49+
#### :house: Internal
50+
51+
- Remove `Stdlib_Char` module for now. https://github.com/rescript-lang/rescript/pull/7367
52+
- Convert internal JavaScript codebase into ESM, ReScript package itself is now ESM (`"type": "module"`). https://github.com/rescript-lang/rescript/pull/6899
53+
- Add built-in support for the JavaScript `in` operator. https://github.com/rescript-lang/rescript/pull/7342
54+
- AST cleanup: add `Pexp_await` ast node instead of `res.await` attribute. (The attribute is still used for await on modules currently). https://github.com/rescript-lang/rescript/pull/7368
55+
56+
#### :nail_care: Polish
57+
58+
- More deprecations in `Pervasives`; add `Stdlib.Pair` and `Stdlib.Int.Ref`. https://github.com/rescript-lang/rescript/pull/7371
59+
60+
# 12.0.0-alpha.10
1461

1562
#### :rocket: New Feature
1663

1764
- Add `Dict.has` and double `Dict.forEachWithKey`/`Dict.mapValues` performance. https://github.com/rescript-lang/rescript/pull/7316
18-
- Add popover attributes to JsxDOM.domProps. https://github.com/rescript-lang/rescript/pull/7317
65+
- Add popover attributes to `JsxDOM.domProps`. https://github.com/rescript-lang/rescript/pull/7317
1966
- Add `Array.removeInPlace` helper based on `splice`. https://github.com/rescript-lang/rescript/pull/7321
2067
- Add `inert` attribute to `JsxDOM.domProps`. https://github.com/rescript-lang/rescript/pull/7326
2168
- Make reanalyze exception tracking work with the new stdlib. https://github.com/rescript-lang/rescript/pull/7328
22-
- Fix Pervasive.max using boolean comparison for floats. https://github.com/rescript-lang/rescript/pull/7333
69+
- Fix `Pervasive.max` using boolean comparison for floats. https://github.com/rescript-lang/rescript/pull/7333
2370
- Experimental: Support nested/inline record types - records defined inside of other records, without needing explicit separate type definitions. https://github.com/rescript-lang/rescript/pull/7241
2471
- Add unified exponentiation (`**`) operator for numeric types using ES7 `**`. https://github.com/rescript-lang/rescript-compiler/pull/7153
2572
- Rename `raise` to `throw` to align with JavaScript vocabulary. `raise` has been deprecated. https://github.com/rescript-lang/rescript/pull/7346
73+
- Add unified bitwise (`^`) operator. https://github.com/rescript-lang/rescript/pull/7216
74+
- Stdlib: rename binary operations to match JavaScript terms. https://github.com/rescript-lang/rescript/pull/7353
2675

2776
#### :boom: Breaking Change
2877

29-
- Replace ~date with ~day in Date.make\*. https://github.com/rescript-lang/rescript/pull/7324
78+
- Replace `~date` with `~day` in `Date.make`. https://github.com/rescript-lang/rescript/pull/7324
3079
- Remove `-bs-jsx-mode`. https://github.com/rescript-lang/rescript/pull/7327
3180
- Drop Node.js version <20 support, as it is reaching End-of-Life. https://github.com/rescript-lang/rescript-compiler/pull/7354
3281
- Treat `int` multiplication as a normal int32 operation instead of using `Math.imul`. https://github.com/rescript-lang/rescript/pull/7358
@@ -38,16 +87,16 @@
3887

3988
#### :nail_care: Polish
4089

41-
- Deprecate JSON.Classify.classify. https://github.com/rescript-lang/rescript/pull/7315
90+
- Deprecate `JSON.Classify.classify`. https://github.com/rescript-lang/rescript/pull/7315
4291
- Hide stdlib modules in output. https://github.com/rescript-lang/rescript/pull/7305
4392
- Deprecate unsafe host-specific bindings from stdlib. https://github.com/rescript-lang/rescript/pull/7334
44-
- Make unsafe function names consistent in Stdlib.String. https://github.com/rescript-lang/rescript/pull/7337
93+
- Make unsafe function names consistent in `Stdlib.String`. https://github.com/rescript-lang/rescript/pull/7337
4594
- `rescript` package does not trigger `postinstall` script anymore. https://github.com/rescript-lang/rescript/pull/7350
46-
- Add Stdlib Bool and Char modules and improve Pervasives deprecation messages. https://github.com/rescript-lang/rescript/pull/7361
95+
- Add Stdlib `Bool` and `Char` modules and improve Pervasives deprecation messages. https://github.com/rescript-lang/rescript/pull/7361
4796

4897
#### :bug: Bug fix
4998

50-
- Fix recursive untagged variant type checking by delaying well-formedness checks until environment construction completes. [#7320](https://github.com/rescript-lang/rescript/pull/7320)
99+
- Fix recursive untagged variant type checking by delaying well-formedness checks until environment construction completes. https://github.com/rescript-lang/rescript/pull/7320
51100
- Fix incorrect expansion of polymorphic return types in uncurried function applications. https://github.com/rescript-lang/rescript/pull/7338
52101

53102
# 12.0.0-alpha.9

CONTRIBUTING.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,19 @@ After adding a new file to the repository that should go into the npm package -
123123

124124
```sh
125125
make lib # Build compiler and standard library
126-
./cli/bsc myTestFile.res
126+
./cli/bsc.js myTestFile.res
127127
```
128128

129129
To view the untyped tree of the file run:
130130

131131
```sh
132-
./cli/bsc -dparsetree myTestFile.res
132+
./cli/bsc.js -dparsetree myTestFile.res
133133
```
134134

135135
To view the typed tree of the file run:
136136

137137
```sh
138-
./cli/bsc -dtypedtree myTestFile.res
138+
./cli/bsc.js -dtypedtree myTestFile.res
139139
```
140140

141141
### Project
@@ -241,39 +241,39 @@ make playground
241241
make playground-cmijs
242242
```
243243

244-
Note that building the cmijs is based on the dependencies defined in `packages/playground-bundling/package.json`. In case you want to build some different version of e.g. `@rescript/react` or just want to add a new package, change the definition within the `package.json` file and run `make playground-cmijs` again.
244+
Note that building the cmijs is based on the dependencies defined in `packages/playground/package.json`. In case you want to build some different version of e.g. `@rescript/react` or just want to add a new package, change the definition within the `package.json` file and run `yarn workspace playground build` again.
245245

246246
After a successful compilation, you will find following files in your project:
247247

248248
- `playground/compiler.js` -> This is the ReScript compiler, which binds the ReScript API to the `window` object.
249-
- `playground/packages` -> Contains third party deps with cmij.js files (as defined in `packages/playground-bundling/bsconfig.json`)
250-
- `playground/compilerCmij.js` -> The compiler base cmij containing all the relevant core modules (`Js`, `Belt`, `Pervasives`, etc.)
249+
- `playground/packages/compiler-builtins` -> The compiler base cmij containing all the relevant core modules (`Js`, `Belt`, `Pervasives`, etc.)
250+
- `playground/packages/*` -> Contains third party deps with cmij.js files (as defined in `packages/playground/rescript.json`)
251251

252252
You can now use the `compiler.js` file either directly by using a `<script src="/path/to/compiler.js"/>` and `<script src="/path/to/packages/compilerCmij.js"/>` inside a html file, use a browser bundler infrastructure to optimize it, or use `nodejs` to run it on a command line:
253253

254254
```
255255
$ node
256-
> require("./compiler.js");
257-
> require("./packages/compilerCmij.js")
258-
> let compiler = rescript_compiler.make()
259-
> let result = compiler.rescript.compile(`Js.log(Sys.ocaml_version)`);
256+
> let { rescript_compiler } = require("./compiler.js");
257+
> require("./packages/compiler-builtins/cmij.js")
258+
> let { rescript } = rescript_compiler.make()
259+
> let result = rescript.compile(`Console.log(${rescript.version})`);
260260
> eval(result.js_code);
261-
4.06.2+BS
262261
```
263262

264263
### Testing the Playground bundle
265264

266-
Run `node playground/playground_test.js` for a quick sanity check to see if all the build artifacts are working together correctly. When releasing the playground bundle, the test will always be executed before publishing to catch regressions.
265+
Run `yarn workspace playground test` for a quick sanity check to see if all the build artifacts are working together correctly. When releasing the playground bundle, the test will always be executed before publishing to catch regressions.
267266

268267
### Working on the Playground JS API
269268

270269
Whenever you are modifying any files in the ReScript compiler, or in the `jsoo_playground_main.ml` file, you'll need to rebuild the source and recreate the JS bundle.
271270

272271
```
273272
make playground
273+
yarn workspace playground build
274274
275275
# optionally run your test / arbitrary node script to verify your changes
276-
node playground/playground_test.js
276+
yarn workspace playground test
277277
```
278278

279279
### Publishing the Playground Bundle on our KeyCDN

0 commit comments

Comments
 (0)