diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a1575d7c83..80eb1cf0cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,9 @@ name: CI on: push: - branches: [master] + branches: [master, 10.0_release] pull_request: - branches: [master] + branches: [master, 10.0_release] jobs: build: diff --git a/.gitignore b/.gitignore index 659f742ede..dc6053a44d 100644 --- a/.gitignore +++ b/.gitignore @@ -148,3 +148,11 @@ jscomp/ml/lexer.ml # opam local switch is stored in `_opam` folder _opam + +.env +playground/packages/ +playground/stdlib/ +playground/*.cmj +playground/*.cmi +playground/.netrc +playground/compiler.js diff --git a/CHANGELOG.md b/CHANGELOG.md index a8b712d738..65d90b5849 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,77 +10,40 @@ > - :house: [Internal] > - :nail_care: [Polish] -# master - -#### :boom: Breaking Change - -- Vendor genType, which does not need to be installed separately anymore. **Only TypeScript back-end** supported. - -#### :nail_care: Polish - -- Print patterns in warnings using rescript printer https://github.com/rescript-lang/rescript-compiler/pull/5492 - -# 10.0 first full release - -- No change yet w.r.t. beta.3 - -# 10.0.0-beta.3 +# 10.0.1 #### :bug: Bug Fix -- Fix issue with compiler log not terminated that causes problems with editor extension not clearing issues when fixed [#5545](https://github.com/rescript-lang/rescript-compiler/issues/5545) - -# 10.0.0-beta.2 - -##### :nail_care: Polish +- Fix issue where watch mode would give an error on Windows https://github.com/rescript-lang/rescript-compiler/pull/5621 -- Changed Linux build to depend on GLIBC 2.28 again for compatibility with Debian 10. +# 10.0.0 -# 10.0.0-beta.1 +**Compiler** #### :boom: Breaking Change - `bsconfig.json` does not support `// line` comments anymore. - Example: `"suffix": ".bs.js" // determine the suffix` - Fix: remove the comment and use standard json. -- Externals without `@val` annotations do not work anymore, and externals with `= ""` give an error. - - Example: `external setTimeout: (unit => unit, int) => float = "setTimeout"` is not supported anymore. - - Fix: use `[@val] external setTimeout: (unit => unit, int) => float = "setTimeout"` instead. - - Example2: `[@val] external setTimeout: (unit => unit, int) => float = ""` is not supported anymore. - - Fix2: use `[@val] external setTimeout: (unit => unit, int) => float = "setTimeout"` instead. -- Regular expressions don't need escaping. - - Example: `let blockCommentsRe = %re("/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*+\\//g")`. - - Fix: use `let blockCommentsRe = %re("/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\//g")` instead. - -#### :bug: Bug Fix - -- Fixed crash in `rescript build` on Windows [#5516](https://github.com/rescript-lang/rescript-compiler/pull/5516) -- Fixed `rescript init` command not working [#5526](https://github.com/rescript-lang/rescript-compiler/pull/5526) - -# 10.0.0-alpha.1 - -**Compiler** - -#### :boom: Breaking Change - -- `@bs.send.pipe` is now removed. Earlier it was deprecated. -- Missing labels in function application is now an error (https://forum.rescript-lang.org/t/ann-more-strict-checks-in-missed-labels/2117). - - Example: `let f = (x, ~z) => x + z; f(1, 2)` - - Fix: do `let f = (x, ~z) => x + z; f(1, ~z=2)` instead - Changed return type of `Js.String.match_` as it was wrong. [#5070](https://github.com/rescript-lang/rescript-compiler/pull/5070) - Example: any use of `Js.String.match_` and `Js.String2.match_` - Fix: follow the type errors #### :rocket: New Feature +- New records with optional fields e.g. `type opt = {x: int, y?: string}` were added as an experimental feature [#5423](https://github.com/rescript-lang/rescript-compiler/pull/5423) [#5452](https://github.com/rescript-lang/rescript-compiler/issues/5452) [New Syntax](https://github.com/rescript-lang/syntax/pull/589/files) - Add support for `@new @variadic` (see https://github.com/rescript-lang/rescript-compiler/pull/5364) -- New records with `@optional` fields [#5423](https://github.com/rescript-lang/rescript-compiler/pull/5423) [#5452](https://github.com/rescript-lang/rescript-compiler/issues/5452) #### :bug: Bug Fix - Classify bigint correctly [#5351](https://github.com/rescript-lang/rescript-compiler/pull/5351) +- Fixed crash in `rescript build` on Windows [#5516](https://github.com/rescript-lang/rescript-compiler/pull/5516) +- Fixed `rescript init` command not working [#5526](https://github.com/rescript-lang/rescript-compiler/pull/5526) +- Fix issue with compiler log not terminated that causes problems with editor extension not clearing issues when fixed [#5545](https://github.com/rescript-lang/rescript-compiler/issues/5545) -#### :house: [Internal] +##### :nail_care: Polish + +- Changed Linux build to depend on GLIBC 2.28 again for compatibility with Debian 10. - Proper M1 support (CI now supports M1 native builds) @@ -88,6 +51,18 @@ #### :boom: Breaking Change +- `@bs.send.pipe` is now removed. Earlier it was deprecated. +- Missing labels in function application is now an error (https://forum.rescript-lang.org/t/ann-more-strict-checks-in-missed-labels/2117). + - Example: `let f = (x, ~z) => x + z; f(1, 2)` + - Fix: do `let f = (x, ~z) => x + z; f(1, ~z=2)` instead +- Externals without `@val` annotations do not work anymore, and externals with `= ""` give an error. + - Example: `external setTimeout: (unit => unit, int) => float = "setTimeout"` is not supported anymore. + - Fix: use `@val external setTimeout: (unit => unit, int) => float = "setTimeout"` instead. + - Example2: `@val external setTimeout: (unit => unit, int) => float = ""` is not supported anymore. + - Fix2: use `@val external setTimeout: (unit => unit, int) => float = "setTimeout"` instead. +- Strings processed at compile-time don't need escaping anymore. + - Example: `let blockCommentsRe = %re("/\\/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*+\\//g")`. + - Fix: use `let blockCommentsRe = %re("/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\//g")` instead. - Remove parsing of "import" and "export" which was never officially supported https://github.com/rescript-lang/syntax/pull/597 https://github.com/rescript-lang/syntax/pull/599 - Example: `export type t = int` - Fix: `@genType type t = int` @@ -96,6 +71,7 @@ #### :rocket: New Feature +- Unicode is now supported in regular strings and chars (when the symbol fits). This is now going to work: `let str = "Σ"`. And, you'll be able to pattern match on unicode chars: `switch c { | 'Σ' => "what a fine unicode char" | _ => "unicode is fun" }` - Doc comments `/** ... */` are now supported. Inernally, they are attributes, so are only valid at positions where `@foo` is allowed, or a syntax error is given. Similarly for module-level `/*** comments */` that can go where `@@attributes` go. #### :bug: Bug Fix @@ -116,6 +92,10 @@ - Fix: use `rescript-relay@beta` or the new version when released. - Removed printing modules (Printf, Format etc) and related functions. Details of files added/removed: https://github.com/rescript-lang/rescript-compiler/commit/0fd8bb0e77c4b0e96a9647ac8af614305057003f. +#### :bug: Bug Fix + +- Fix library issue with missing `bytes_to_string` https://github.com/rescript-lang/rescript-compiler/issues/5573 https://github.com/rescript-lang/rescript-compiler/pull/5589 + #### :nail_care: Polish - Several Belt / Js libraries are now converted to ReScript syntax, with corresponding comments in Markdown format suitable for hovering. See [#5361](https://github.com/rescript-lang/rescript-compiler/pull/5361). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b23329b761..d6307ab25a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -99,58 +99,49 @@ dune build -w > Please note that `dune` will not build the final `rescript` binaries. Use the aforementioned `ninja` workflow if you want to build, test and distribute the final product. -## Adding new Files +## Adding new Files to the Npm Package 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. -When adding a new file to the repository that should go into the npm package - e.g., a new stdlib module -, first compile and test everything locally. Next, run `./scripts/makeArtifactList.js` to update the artifact list and include the updated artifact list in your commit. +When adding a new file to the repository that should go into the npm package - e.g., a new stdlib module -, first compile and test everything locally. Then -## Running tests for independent ReScript files +- `node scripts/install -force-lib-rebuild` to copy library files into `lib/ocaml` +- `./scripts/makeArtifactList.js` to update the artifact list and include the updated artifact list in your commit. -The simplest way for running tests is to run your locally built compiler on separate ReScript files: +## Test the compiler -```sh -# Make sure to rebuild the compiler before running any tests (./scripts/ninja.js config / build etc) -./darwinarm64/bsc.exe myTestFile.res -``` - -**Different architectures:** - -- `darwinarm64/bsc.exe`: M1 Macs -- `darwin/bsc.exe`: Intel Macs -- `linux/bsc.exe`: Linux computers +Make sure to build the compiler first following the instructions above. -### Testing the whole ReScript Package - -If you'd like to bundle up and use your modified ReScript like an end-user, try: +### Single file ```sh -node scripts/install -force-lib-rebuild # make sure lib/ocaml is populated - -npm uninstall -g rescript # a cache-busting uninstall is needed, but only for npm >=7 - -# This will globally install your local build via npm -RESCRIPT_FORCE_REBUILD=1 npm install -g . +./bsc myTestFile.res ``` -Then you may initialize and build your ReScript project as usual: +### Project ```sh -rescript init my-project -cd my-project -npm run build +node scripts/install -force-lib-rebuild ## populate lib/ocaml +cd myProject +npm install __path_to_this_repository__ ``` ### Running Automatic Tests We provide different test suites for different levels of the compiler and build system infrastructure. Always make sure to locally build your compiler before running any tests. -**Run Mocha tests for our runtime code:** +To run all tests: + +```sh +npm test +``` + +**Run Mocha tests only (for our runtime code):** This will run our `mocha` unit test suite defined in `jscomp/test`. ``` -npx node scripts/ciTest.js -mocha +node scripts/ciTest.js -mocha ``` **Run build system test (integration tests):** @@ -158,10 +149,7 @@ npx node scripts/ciTest.js -mocha This will run the whole build system test suite defined in `jscomp/build_tests`. ``` -# Make sure to globally install rescript via npm first -npm install -g . - -npx node scripts/ciTest.js -bsb +node scripts/ciTest.js -bsb ``` **Run ounit tests:** @@ -169,14 +157,14 @@ npx node scripts/ciTest.js -bsb This will run unit tests for compiler related modules. The tests can be found in `jscomp/ounit_tests`. ``` -npx node scripts/ciTest.js -ounit +node scripts/ciTest.js -ounit ``` -## Contributing to the ReScript Runtime +## Contributing to the Runtime -Our runtime implementation is written in pure OCaml with some raw JS code embedded (`jscomp/runtime` directory). +The runtime implementation is written in OCaml with some raw JS code embedded (`jscomp/runtime` directory). -The goal is to implement the runtime **purely in OCaml**. This includes removing all existing occurrences of embedded raw JS code as well, and you can help! +The goal is to implement the runtime **purely in OCaml**. This includes removing all existing occurrences of embedded raw JS code as well whenever possible, and you can help! Each new PR should include appropriate testing. @@ -184,8 +172,8 @@ Currently all tests are located in the `jscomp/test` directory and you should ei There are currently two formats for test files: -1. Proper mocha test files with executed javascript test code -2. Plain `.ml` files which are only supposed to be compiled to JS (without any logic validation) +1. Mocha test files that run javascript test code +2. Plain `.ml` files to check the result of compilation to JS (expectation tests) Below we will discuss on how to write, build and run these test files. @@ -241,35 +229,50 @@ mkdir playground && mkdir playground/stdlib # We build the ReScript source code and also the bytecode for the JSOO entrypoint node scripts/ninja.js config && node scripts/ninja.js build -# Now we run the repl.js script pointing to our playground directory (note how it needs to be relative to the repl.js file) -PLAYGROUND=../playground node scripts/repl.js +# Now we run the repl.js script which will create all the required artifacts in the `./playground` directory +node scripts/repl.js +``` + +In case you want to build the project with our default third party packages (like `@rescript/react`), prepare the `playground-bundling` project and then run `repl.js` with `BUILD_THIRD_PARTY` enabled: + +``` +# Prepare the `playground-bundling` project to allow building of the third party cmij packages +npm link +cd packages/playground-bundling +npm install +npm link rescript + +BUILD_THIRD_PARTY=true node scripts/repl.js ``` _Troubleshooting: if ninja build step failed with `Error: cannot find file '+runtime.js'`, make sure `ocamlfind` is installed with `opam install ocamlfind`._ After a successful compilation, you will find following files in your project: -- `playground/exports.js` -> This is the ReScript compiler, which binds the ReScript API to the `window` object. +- `playground/compiler.js` -> This is the ReScript compiler, which binds the ReScript API to the `window` object. - `playground/stdlib/*.js` -> All the ReScript runtime files. +- `playground/packages` -> Contains third party deps with cmij.js files (as defined in `packages/playground-bundling/bsconfig.json`) -You can now use the `exports.js` file either directly by using a `