diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index af711891e8..66d68218be 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -196,8 +196,6 @@ This is usually the file you want to create to test certain compile behavior wit ## 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 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/4.0.0/manual/overview), which uses OCaml bytecode to compile to JavaScript and is part of the bigger OCaml ecosystem. @@ -210,84 +208,47 @@ opam install js_of_ocaml.4.0.0 ### Building the Bundle -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 the JSOO entrypoint -node scripts/ninja.js config && node scripts/ninja.js build - -# 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: +The entry point of the JSOO bundle is located in `jscomp/jsoo/jsoo_playground_main.ml`, the compiler and its relevant runtime cmij files can be built via make: -``` -# 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 +```sh +make playground +make playground-cmijs ``` -_Troubleshooting: if ninja build step failed with `Error: cannot find file '+runtime.js'`, make sure `ocamlfind` is installed with `opam install ocamlfind`._ +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. After a successful compilation, you will find following files in your project: - `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`) +- `playground/compilerCmij.js` -> The compiler base cmij containing all the relevant core modules (`Js`, `Belt`, `Pervasives`, etc.) -You can now use the `compiler.js` file either directly by using a `