Skip to content

Latest commit

 

History

History
68 lines (55 loc) · 1.74 KB

installation.md

File metadata and controls

68 lines (55 loc) · 1.74 KB
title
Installation

Note: for general Reason + BuckleScript editor setup, see here.

BuckleScript

BuckleScript compiles ReasonML code to JavaScript. You can get it with:

npm install --global [email protected]
bsb -init my-react-app -theme react-hooks
cd my-react-app && npm install && npm start
# in another tab
npm run server

BuckleScript's bsb build system has an init command that generates a project template. The react-hooks theme happens to be our official, lightweight template optimized for low learning overhead and ease of integration into an existing project.

The .re files compile to straightforward .bs.js files. You can open index.html directly from the file system. No server needed! Change any .re file to see that page automatically refreshed.

Adding Reason + Bucklescript to an existing project

Install the following dependencies:

yarn add [email protected] --dev --exact
yarn add reason-react --exact

Add scripts to package.json:

"scripts": {
  "re:build": "bsb -make-world -clean-world",
  "re:watch": "bsb -make-world -clean-world -w"
}

Create a bsconfig.json file in the root of your project with the following. You can change the name.

{
  "name": "your-project-name",
  "reason": { "react-jsx": 3 },
  "bsc-flags": ["-bs-super-errors"],
  "sources": [
    {
      "dir": "src",
      "subdirs": true
    }
  ],
  "package-specs": [
    {
      "module": "es6",
      "in-source": true
    }
  ],
  "suffix": ".bs.js",
  "namespace": true,
  "bs-dependencies": [
    "reason-react"
  ],
  "ppx-flags": [],
  "refmt": 3
}