Melange
A mixture of tooling combined to produce JS from OCaml / Reason.
This project is a fork of the ReScript compiler with a focus on compatibility with the wider OCaml ecosystem. A small write-up with more details on the motivation behind this project can be found in this blog post.
Installation
This project is currently unreleased. Currently, the most straightforward way to use it is via Esy.
- Make sure you have Esy installed (
npm install -g esy
should cover most workflows) - Use an
esy.json
file like the following:
{
"name": "melange-project",
"dependencies": {
"ocaml": "4.12.x",
"melange": "melange-re/melange",
"@opam/ocaml-lsp-server": "*"
},
"esy": {
"buildsInSource": "unsafe",
"build": ["ln -sfn #{melange.install} node_modules/bs-platform"]
},
"installConfig": {
"pnp": false
}
}
-
Run
npm install
(oryarn
) followed by justesy
and after they finish installing and building, you should be able to usebsb
commands via esyesy bsb -make-world
-
Reach out on the ReasonML Discord if you can't figure it out!
FAQ
How does this project relate to other tools?
Name | Purpose | Dependencies | Notes |
---|---|---|---|
Esy | Package manager | Installed with NPM | Obtaining dependencies (e.g. dune or reason ) |
Dune | Build tool | Installed with esy |
Well-known OCaml build tool; supports custom rules that can be composed to build anything |
Reason | Syntax | Installed with esy |
a library that implements an alternative syntax to OCaml |
Melange | Compiler that emits JavaScript | Esy (to install), Dune (to build), Reason (used as a library) | Supports OCaml, Reason and ReScript syntaxes; derived from ReScript, focused on compatibility with the wider OCaml ecosystem |
ReScript | The brand around a syntax and a compiler that emits JavaScript | None | Distributed via NPM as prebuilt binaries; previously called BuckleScript |
Can I use ReScript syntax?
Yes! ReScript syntax is supported, but beware that it's stuck on an ancient
OCaml version (4.06, released in 2018), and it won't have as many features as
the OCaml or Reason syntaxes
(e.g. letop
binding operators,
generalized module open expressions,
or local substitutions in signatures).
refmt
flag gone?
Where has the Upstream removed the refmt
flag, which used to allow configuring the path to a custom Reason binary. This
was a welcome change for this repo too, so we cherry-picked it. The rationale:
this project uses Reason as a library,
so you can simply depend on the Reason version that you'd like in the usual way,
via your preferred package manager.
Contributing
See CONTRIBUTING.md.
Acknowledgments
See Credits.md.
Licensing
See COPYING and COPYING.LESSER
See Credits for more details.