bsc compiler api for the new syntax serves two purposes:
- formatting a new syntax file (
- converting over existing OCaml/Reason file.
Assuming you have
npm install email@example.com installed, do:
path/to/bsc -fmt YourFile. The api knows to either just format or to convert OCaml/Reason syntax over, depending on
This command line flag isn’t stable yet; it’s intended for manual usage, to gather feedback. The conversion from Reason to the new syntax happens to be a nontrivial amount of work under the hood, thus our cautiousness. Please try them on your complex files in your codebase and see if you get any error. Here’s our tip:
- Make sure you’ve already checked in your
.bs.jsoutput like we recommended for the project setup. If you haven’t, that’s fine too: just create a new branch in your version control, run the build and check in the BS js output (probably by un-ignoring
- Run e.g.
node_modules/.bin.bsc -fmt YourFile.re > YourFile.res.
mv YourFile.re YourFile.re.backup, to make the build ignore your old file.
- Run the build. Check if there’s any new
.bs.jsoutput changes. If not, then congratulations, you’re done!
- If there are nontrivial output changes, please file an issue here.
We’ll be releasing a more fully-featured conversion tool and in-editor formatter afterward, but there’s nothing wrong with converting your project over now if you’ve detected no error. One fewer thing to do in the future.