You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Upgrading the Reason version within BuckleScript
316
+
317
+
Each BuckleScript release is coupled to a specific Reason syntax version, which currently needs to be updated manually once in a while.
318
+
319
+
It's important that we need to update two specific files:
320
+
321
+
-`jscomp/main/refmt_api.ml`: Contains the programmatic interface for the refmt syntax converter (responsible for transforming Reason string code to an OCaml AST) -> Only used in the BuckleScript JS Playground
322
+
-`lib/4.06.1/refmt_main3.ml`: The refmt binary used within BuckleScript itself. The `3` corresponds to the corresponding major version of refmt -> Used to build the vendored `refmt`, aka. `bsrefmt`
323
+
324
+
Both files are generated by using the `jscomp/bin/bspack.exe` binary (which is also built automatically when you build the compiler inside this repository) on the refmt parser. In more detail, `bspack.exe` resolves all dependencies of one specific `.ml` input file, puts them in the right order and copies all the source code with the target input file in one huge `.ml` bundle.
325
+
326
+
So the two files mentioned above, `refmt_api.ml` and `refmt_main3.ml`, are bspacked within the Reason repository and then checked into the BuckleScript repository (we call this `vendoring` or `snapshotting`).
327
+
Here are the instructions on building your own Reason snapshots (make sure you to have everything set up for building the playground bundle first, as mentioned above):
328
+
329
+
```
330
+
# Let's go up one level and clone Reason in a sibling directory next to your `bucklescript` repo
331
+
cd ..
332
+
git clone https://github.com/facebook/reason
333
+
334
+
cd reason
335
+
336
+
# You should already have created this switch by now, see playground build setup instructions in "Contributing to the BS Playground Bundle"
337
+
opam switch 4.06.1
338
+
opam pin add -y reason .
339
+
opam pin add -y rtop .
340
+
341
+
# Let's do the bspacking process for refmt_api.ml and refmt_binary.ml
342
+
cd bspacks
343
+
344
+
# Initial setup of certain dependencies before we can bspack everthing in one file
You should now have the newest `refmt` binary for the actual compiler, and for the playground, a new `playground/exports.js` file with the new Reason version included.
366
+
367
+
**Important:** Always verify that the updated Reason version is in sync in the
368
+
`refmt.exe` and the playground bundle. Use `lib/bsrefmt --version` and for the
369
+
playground API `window.reason.version` (not final) to get the bundled
Copy file name to clipboardExpand all lines: jscomp/README.md
-27Lines changed: 0 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,32 +1,5 @@
1
1
Hello! This is the main directory for BuckleScript. `jscomp` is just a name that mirrors OCaml's own `bytecomp` and `asmcomp` (bytecode compilation and native compilation logic respectively). For building it, please see [CONTRIBUTING.md](../CONTRIBUTING.md).
2
2
3
-
Extra info:
4
-
5
-
## Rebuilding the browser-based playground
6
-
7
-
For best results, you probably want to complete the full [Setup](../CONTRIBUTING.md#setup) before following the below guidelines.
8
-
9
-
### Get `js_of_ocaml` from the normal switch
10
-
11
-
```
12
-
opam switch 4.02.3
13
-
eval `opam config env`
14
-
opam install js_of_ocaml
15
-
which js_of_ocaml # symlink this into your $PATH, maybe /usr/local/bin or something
16
-
```
17
-
18
-
### Do everything else from the bucklescript switch
19
-
20
-
You need to have [bucklescript-playground](https://github.com/BuckleScript/bucklescript-playground) cloned next to the Bucklescript directory for the following to work.
0 commit comments