This document explains the extended set of tools being developed as part of the Reason project (including community collaborations). This document is a guide for the curious, and for people looking to branch out of the most common workflows for Reason or find out about tools being devloped in various stages. There are other tools not focused on in this document that overlap in purpose with some of these tools, but this document will focus on the tools developed under the Reason umbrella (including community collaborations), all of which have the ultimate goal of being approachable to the web community and people coming from JavaScript/React ecosystems.
If you're brand new to Reason and just want to get started as quickly as possible with compiling to JS, just go through the main docs instead.
You've at least dabbled in Reason, and you've noticed that Reason can do much more than just compile to JavaScript. How do you do that, what tools are required, and what do you need to learn?
Additional tools:
Depending on which of those goals you're pursuing, there is different tooling required. Ideally the tools for these workflows would be unified into just one. That may not happen overnight, but we can work towards that ideal state, and this high level overview will make it clear what needs to happen. We're not going to describe that ideal state just yet - for now, let's just describe how things currently work and which tools are involved.
The Universe of All Packages is split into two kinds.
When developing native packages, you will encounter the following tooling. We'll also note the analogous concept in the JavaScript/node ecosystem.
| Tool | Description | Analogous to JS tool |
|---|---|---|
esy | Package manager for native Reason. | npm |
package.json or esy.json | Just like with npm package.json file. Used to configure dependencies. | package.json |
dune | Native Build system for Reason/OCaml. | webpack |
pesy | Helps create new project, and generates dune config. | create-react-app |
merlin | Provides autocomplete support in editors. | |
"esy": {"build": "my command"} | The command in your package.json that will be run when your package is developed or installed as a dependency. Usually this command just tells dune to perform the build. | "postinstall": "build command" |
| "ppx" | Tools that transform your source code at build time. These are per-file transforms. | Babel plugins. |
How does using those those tools for native development differ than when developing BuckleScript projects?
| BuckleScript Packages | Native Packages | |
|---|---|---|
| Package Manager: | npm | esy |
| Package Config: | package.json | package.json (or esy.json) |
| Can Use Dependencies: | JS dependencies or other BuckleScript packages. | Native packages |
| Dependencies Hosted: | On npm. | On opam "@opam/pkg-name", or on npm "native-pkg-hosted-on-npm" |
| Project Install+build | npm installbsb | esy |
| Build System | bsb (included with bs-platform) | Dune |
| Required Project Dependencies: | bs-platform | ocaml, dune |
| Build Config | bsconfig.json | One dune config file per directory in project. |
| Compiler: | │ Reason Syntax │ OCaml Type System v BuckleScript JS backend .js files | │ Reason Syntax │ OCaml Type System v Native OCaml backend .exe |
| Simplified Workflow: | npm install -g bs-platformbsb -init | npm install -g esy pesypesy |
To simplify everything, here are some things you can help out with to help us consolidate tooling and remove confusion/complexity.
esy, but keep everything else the same.npm with esy, but still using the rest of the BuckleScript tools.esy for native and esy for BuckleScript projects.9 commits
This document explains the extended set of tools being developed as part of the Reason project (including community collaborations). This document is a guide for the curious, and for people looking to branch out of the most common workflows for Reason or find out about tools being devloped in various stages. There are other tools not focused on in this document that overlap in purpose with some of these tools, but this document will focus on the tools developed under the Reason umbrella (including community collaborations), all of which have the ultimate goal of being approachable to the web community and people coming from JavaScript/React ecosystems.
If you're brand new to Reason and just want to get started as quickly as possible with compiling to JS, just go through the main docs instead.
You've at least dabbled in Reason, and you've noticed that Reason can do much more than just compile to JavaScript. How do you do that, what tools are required, and what do you need to learn?
Additional tools:
Depending on which of those goals you're pursuing, there is different tooling required. Ideally the tools for these workflows would be unified into just one. That may not happen overnight, but we can work towards that ideal state, and this high level overview will make it clear what needs to happen. We're not going to describe that ideal state just yet - for now, let's just describe how things currently work and which tools are involved.
The Universe of All Packages is split into two kinds.
When developing native packages, you will encounter the following tooling. We'll also note the analogous concept in the JavaScript/node ecosystem.
| Tool | Description | Analogous to JS tool |
|---|---|---|
esy | Package manager for native Reason. | npm |
package.json or esy.json | Just like with npm package.json file. Used to configure dependencies. | package.json |
dune | Native Build system for Reason/OCaml. | webpack |
pesy | Helps create new project, and generates dune config. | create-react-app |
merlin | Provides autocomplete support in editors. | |
"esy": {"build": "my command"} | The command in your package.json that will be run when your package is developed or installed as a dependency. Usually this command just tells dune to perform the build. | "postinstall": "build command" |
| "ppx" | Tools that transform your source code at build time. These are per-file transforms. | Babel plugins. |
How does using those those tools for native development differ than when developing BuckleScript projects?
| BuckleScript Packages | Native Packages | |
|---|---|---|
| Package Manager: | npm | esy |
| Package Config: | package.json | package.json (or esy.json) |
| Can Use Dependencies: | JS dependencies or other BuckleScript packages. | Native packages |
| Dependencies Hosted: | On npm. | On opam "@opam/pkg-name", or on npm "native-pkg-hosted-on-npm" |
| Project Install+build | npm installbsb | esy |
| Build System | bsb (included with bs-platform) | Dune |
| Required Project Dependencies: | bs-platform | ocaml, dune |
| Build Config | bsconfig.json | One dune config file per directory in project. |
| Compiler: | │ Reason Syntax │ OCaml Type System v BuckleScript JS backend .js files | │ Reason Syntax │ OCaml Type System v Native OCaml backend .exe |
| Simplified Workflow: | npm install -g bs-platformbsb -init | npm install -g esy pesypesy |
To simplify everything, here are some things you can help out with to help us consolidate tooling and remove confusion/complexity.
esy, but keep everything else the same.npm with esy, but still using the rest of the BuckleScript tools.esy for native and esy for BuckleScript projects.9 commits