This article is the first of a serie dedicated to ReasonML: A journey into ReasonML. This language, created by Facebook, featured in my 2018 “To Learn” list for quite some time. I finally taken the time to work on it. The year is wrapping up but it still count, right? The purpose of the serie is to share my experience learning ReasonML from zero as a JS engineer.
When developing with React, there is chance you’ve come accross create-react-app (CRA). It helps bootstrap your project allowing you to focus on your code rather than your build chain. Of course, one would look for such tool when starting with ReasonML. There was a project integrating with CRA
which aimed at replacing
For the actual setup I recommend this great tutorial by Khoa Nguyen, from the ReasonML community.
One thing I’d like to add from his tutorial is that you can either:
- Run CRA in one terminal to watch JS files and also run
bsbin another terminal to watch ReasonML files.
- Rely on your editor plugin to run
Personally I prefer the former because sometimes I ran into issues where compilation errors were not picked up by the editor thus failing the build without knowing it.
Fix your entrypoint
By now, you should have CRA and the ReasonML tooling set up. But we need to add a little something. If you followed the tutorial I linked the JS files created by BuckleScript are suffixed by
.bs.js however CRA configuration looks for an
index.js file in your
src/ folder. To satisfy this requirement, you just need to create it with the content:
You have everything you need to start building awesome things. Happy hacking! 🎉
If you decide to have fun with ReasonML, as I did, I highly recommend you to join the ReasonML community on Discord. People there are really friendly and supportive. They helped me tremendously.