Home

Awesome

Melange

Melange compiles OCaml / Reason to JavaScript

Powered by the versatile OCaml type system, with best-in-class type inference, Melange produces robust JavaScript code.

Sponsored by:

<div style="display: inline;"> <a href="https://ahrefs.com"> <img src="./docs/images/ahrefs-logo.png" height="50px"> </a> <a href="https://ocaml-sf.org/"> <img src="./docs/images/ocsf_logo.svg" height="50px"> </a> <div style="display: inline; margin-left: 6px;"> <a href="https://www.instapainting.com"> <img src="./docs/images/instapainting-logo.png" height="30px"> </a> </div> </div>

Installation

Check melange.re to get started.

OPAM

Melange is released to OPAM. Install it with:

$ opam install melange

Template

melange-re/melange-opam-template provides a GitHub template repository that can be used as a project starter.

Nix

Melange has good support for Nix:

OCaml version compatibility

Editor integration

Melange has first class support in Dune. ocaml-lsp or Merlin works as usual. In VSCode, the VSCode OCaml Platform extension is recommended.

Community

FAQ

How does this project relate to other tools?

This project is forked from an earlier version of the ReScript compiler, focused on a deeper integration with the OCaml ecosystem. Such integration makes it easy to share code between backend and frontend using e.g. Dune's virtual libraries.

Melange 1.0 includes a ReScript compatibility layer to maintain compatibility with ReScript syntax - preserving access to ReScript's package ecosystem. Both ReScript and Melange have diverged significantly since then, and this compatibility layer was removed in Melange 2.0.

A small write-up with more details on the motivation behind this project can be found in the announcement blog post. Additional write-ups exist at anmonteiro.substack.com

Below is a quick comparison between Melange and other tools:

NamePurposeDependenciesNotes
OPAMPackage managerNoneObtaining dependencies such as dune or reason
DuneBuild toolInstalled with e.g. opamComposable build tool for OCaml; supports composing custom rules to build any project
ReasonSyntaxInstalled with e.g. opamAlternative syntax to OCaml
MelangeCompiler that emits ScriptOPAM (to install), Dune (to build)Supports OCaml and Reason; derived from ReScript, focused on deeper integration with OCaml
ReScriptThe brand around a syntax and a compiler that emits JavaScriptNoneDistributed via NPM as prebuilt binaries; previously called BuckleScript

Contributing

See CONTRIBUTING.md.

Acknowledgments

See also Credits.md concerning some individual components of Melange.

Licensing

See COPYING and COPYING.LESSER

See Credits for more details.