Powered by the versatile OCaml type system, with best-in-class type inference, Melange produces robust JavaScript code.
Sponsored by:
Melange is released to OPAM. Install it with:
$ opam install melangemelange-re/melange-opam-template provides a GitHub template repository that can be used as a project starter.
Melange has good support for Nix:
github:melange-re/melange can be added as a flake inputmelange.overlays.default overlay that adds melange to pkgs.ocamlPackages.melangemelc binary can be run with nix run github:melange-re/melange, e.g. nix run github:melange-re/melange/1.0.0 -- --helpGet Esy on NPM:
npm install -g esy installs Esy globallynpm is installed, npx esy can be used to run Esy locallyAn Esy project starter also exists.
After cloning the template, run esy in the project root.
Melange >= v1.0 can build projects on OCaml >= 4.13 (including OCaml 5.x). Editor integration only works on OCaml 4.14, because Melange emits .cmt artifacts targeting the OCaml 4.14 binary format.
Melange has first class support in Dune. ocaml-lsp or Merlin works as usual. In VSCode, the VSCode OCaml Platform extension is recommended.
#melange channel in the ReasonML DiscordThis project is forked from the ReScript compiler, focused on a deeper integration with the OCaml ecosystem. This allows sharing code between backend and frontend using Dune's virtual libraries.
Melange also introduces a ReScript compatibility layer to maintain compatibility with ReScript syntax - preserving access to ReScript's package ecosystem. It's only recommended to use it with Melange v1, as both ReScript and Melange have diverged significantly since then.
A small write-up with more details on the motivation behind this project can be found in the announcement blog post.
Below is a quick comparison between Melange and other tools:
Name | Purpose | Dependencies | Notes |
|---|---|---|---|
Package manager | Installed with NPM | Obtaining dependencies such as | |
Package manager | None | Obtaining dependencies such as | |
Build tool | Installed with e.g. | Composable build tool for OCaml; supports composing custom rules to build any project | |
Syntax | Installed with e.g. | Alternative syntax to OCaml | |
Compiler that emits Script | Esy / OPAM (to install), Dune (to build) | Supports OCaml, Reason and ReScript syntax; derived from ReScript, focused on deeper integration with OCaml | |
The brand around a syntax and a compiler that emits JavaScript | None | Distributed via NPM as prebuilt binaries; previously called BuckleScript |
See CONTRIBUTING.md.
See also Credits.md concerning some individual components of Melange.
See COPYING and COPYING.LESSER
See Credits for more details.