diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 850712783a..1fb79cb6ab 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -209,43 +209,38 @@ This is usually the file you want to create to test certain compile behavior wit - Verify the output, check in the `jscomp/test/my_file_test.ml` and `jscomp/test/my_file_test.js` to version control. The checked in `.js` file is essential for verifying regressions later on. - Eventually check in other relevant files changed during the rebuild (depends on your compiler changes). -## Contribute to the BS Playground Bundle +## Contribute to the ReScript Playground Bundle > Note: These instructions are designed for building the 4.06 based version of ReScript (ReScript v6). -The "Playground bundle" is the BS compiler compiled to JavaScript, including all necessary dependency files (stdlib / belt etc). It is useful for building tools where you want to compile and execute arbitrary Reason / OCaml in the browser. +The "Playground bundle" is a JS version of the ReScript compiler; including all necessary dependency files (stdlib / belt etc). It is useful for building tools where you want to compile and execute arbitrary ReScript code in the browser. -The ReScript source code is compiled with a tool called [JSOO (js_of_ocaml)](https://ocsigen.org/js_of_ocaml/3.5.1/manual/overview), which uses OCaml bytecode to compile to JavaScript and is part of the bigger OCaml ecosystem. Before we can compile anything, we need to install the required tools (requires [`opam`](https://opam.ocaml.org/doc/Install.html) to be installed): +The ReScript source code is compiled with a tool called [JSOO (js_of_ocaml)](https://ocsigen.org/js_of_ocaml/4.0.0/manual/overview), which uses OCaml bytecode to compile to JavaScript and is part of the bigger OCaml ecosystem. -```sh -# Create the right switch, if not created yet (first install) -opam switch create 4.06.1 - -# Makes sure to be on the right switch -opam switch 4.06.1 -eval `opam config env` +Install `jsoo` via `opam`: -opam install js_of_ocaml.3.5.1 +```sh +opam install js_of_ocaml.4.0.0 ``` -### Build the Bundle +### Building the Bundle -The entry point of the JSOO bundle is located in `jscomp/main/jsoo_main.ml` and the script for running JSOO can be found in `scripts/repl.js`. A full clean build can be done like this: +The entry point of the JSOO bundle is located in `jscomp/main/jsoo_playground_main.ml`, the code for packing the compiler into a single compiler file is located in `jscomp/snapshot.ninja`, and the script for running JSOO can be found in `scripts/repl.js`. A full clean build can be done like this: ``` # We create a target directory for storing the bundle / stdlib files mkdir playground && mkdir playground/stdlib -# We build the ReScript source code and also the bytecode for jsoo_main.ml +# 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) -BS_PLAYGROUND=../playground node scripts/repl.js +PLAYGROUND=../playground 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`._ -**You should now find following files:** +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/stdlib/*.js` -> All the ReScript runtime files. @@ -255,44 +250,40 @@ You can now use the `exports.js` file either directly by using a `