melange-re /melange
A mixture of tooling combined to produce JavaScript from OCaml & Reason
★ 997⑂ 64👁 16⑃ 1,928● 269▤ 49
-1
Daily
997
stars
64
forks
16
watchers
1,928
prs
269
issues
49
releases
README
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.
+ Melange
Installation
- OPAM
- Nix
- OCaml version compatibility
Editor integration
Community
FAQ
- How does this project relate to other tools?
Contributing
Acknowledgments
Licensing
Sponsored by:
Installation
Check melange.re to get started.
OPAM
Melange is released to OPAM. Install it with:
shell
$ 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:
- github:melange-re/melange can be added as a
flake input
- the melange flake provides a melange.overlays.default overlay that adds
melange to pkgs.ocamlPackages.melange
- the melc binary can be run with nix run github:melange-re/melange, e.g.
nix run github:melange-re/melange/2.0.0 -- --help
OCaml version compatibility
- Melange v3.0 works on OCaml 4.14 (v3-414) and 5.1 (v3-51).
- Melange v2.0 works on OCaml 5.1 only.
- Melange v1.0 can build projects with 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.
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
- There's a melange channel in the
ReasonML Discord
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:
| Name | Purpose | Dependencies | Notes |
| -------------------------------------- | -------------------------------------------------------------- | ---------------------------------- | ----------------------------------------------------------------------------------- |
| OPAM | Package manager | None Top issues
#135A logo, mascot, or other representation for the project21 comments · 2021-04-03#674[@bs] at application side treats `f ()` as 0-arity application18 comments · 2023-08-04#34Windows Support15 comments · 2021-03-20#164Compile OCaml with Melange10 comments · 2021-04-07#166RFC: Errors for Reason6 comments · 2021-04-08#1154Js__Js_xxx.t appears on type-errors and hovering 4 comments · 2024-07-19#1022Strange behavior when using `unit` in externals3 comments · 2024-01-09#567Standard library status3 comments · 2023-05-11
Discussions
#1130Am I understanding how Melange integrates with JS and NPM correctly?1 comments · 2024-05-31#1088I'm unable to use pprint library using melange.1 comments · 2024-03-16#694dune config for SSR with native code on the server5 comments · 2023-08-20#688Libraries and bindings authoring and publishing0 comments · 2023-08-11#626Welcome to Melange Discussions!0 comments · 2023-06-14
Latest release
7.0.1-55 7.0.1-55 2026-07-12CHANGES: - fix: avoid relocating relative mel.module externals when inlining (1799, 1800)