Image for post
Image for post

How to start a minimal ReasonML project — without boilerplate

I was reading the quickstart guide and that is nice when you are reading about ReasonML for the first time or are starting from scratch, but what if you want to do it yourself or want to incoporate it into an existing project? This is a guide how to minimally get started with ReasonML without using a boilerplate.

The first thing we need is a bsconfig.json , that is needed for the Bucklescript compiler that turns the ReasonML into JavaScript.

It looks like this:

It is pretty simple, but let explain them:

  • name: your projects name or more used for if you make a library
  • version: What version your app is
  • sources: Configuration for Bucklescript where to look for the code
  • package-specs: In which format the code should be outputted
  • suffix: Which fileending the files should have after compilation
  • bs-dependencies: if you used any dependencies from
  • warnings: Here you can turn on/off errors
  • refmt: What version of the ReasonML formatter that is running

With that file out of the way, you need only to add bs-platform to your npm dependencies. If you don’t have a package.json, you can quickly add one with npm init .

and then you can add these commands to your package.json

  • clean removes any potentially left over files from previous build
  • build compiles all the code once
  • watch continuesly build whenever a change has happend in the source folder

When you installed bs-platform it added a lib folder. Add that folder to .gitignore .

To test this, add a file at ./src/ and put Js.log("Hello"); and run npm run watch . You should see a file called ./src/ with

And you are done! This is what you need and now you know how to get started without a boilerplate

Written by

I really like building stuff with React.js and Docker and also Meetups ❤

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store