Hey folks, this is a special one.
Melange 1.0
The Melange team and I are thrilled to announce the release of Melange 1.0 today, marking a major milestone in the life of the project. This release represents the culmination of many months of hard work and incredible collaboration.
Melange, which started as a fork of BuckleScript, was created with the vision of maintaining compatibility with OCaml and providing the best OCaml experience within the modern JavaScript ecosystem. Today, we are proud to present Melange 1.0, a mature and reliable tool for compiling OCaml to efficient and readable JavaScript that teams rely on to deliver complex OCaml / ReasonML applications.
$ opam install melange.1.0.0
Highlights
Melange 1.0 radically improves user experience. This release focuses on robustness, OCaml compatibility and developer experience: Melange is fully embracing the OCaml Platform to make it easy and reliable for OCaml users to target JavaScript.
Dune Integration
Integrating with Dune was our biggest priority. Dune 3.8, released very recently, adds Melange support by understanding the following types of stanzas:
(library
(modes melange) ;; <- new Melange mode
)
;; emit JS to `js-output` folder in this
;; directory
(melange.emit
(target js-output))
In Melange 1.0, the Dune integration is the officially supported workflow to build Melange projects. It provides robust rule generation, static assets support (your HTML / CSS / SVG / images), seamless editor integration (e.g. with OCaml LSP or Merlin).
Documentation
With Melange 1.0, we’re also launching a new documentation effort, melange.re. This website should currently be considered a work in progress, and we’re looking for feedback on how to best explain the Melange workflow and its available features. Feel free to get in touch in the OSS repository.
Additionally, the Dune documentation includes reference materials specific to using Melange with Dune.
Everything else
Wider OCaml version support
Melange was previously only available on OCaml 4.14. In this release, we’ve widened that range to versions of OCaml starting from version 4.13. This includes the OCaml 5 release line and allows Melange projects to share the same OCaml compiler switch as e.g. server-side projects.
Editor integration is the only caveat: it only works on OCaml 4.14, since Melange emits .cmt
artifacts (used by e.g. LSP) targeting the OCaml 4.14 binary format.
Multiple syntaxes
Dune supports ReasonML out of the box via dialects, keeping ReasonML support in Melange unchanged from a user perspective. Internally, however, Melange 1.0 has dropped any knowledge of ReasonML, relying on the existing, battle-tested Dune support for dialects instead.
A rescript-syntax
package is part of the Melange release too. It enables support for ReScript syntax in Melange, which Dune also supports. Keep in mind, however, that newer ReScript features are unlikely to be supported by this best-effort compatibility package.
Separate PPX
A big benefit of deep integration with the OCaml platform is having the freedom to assume that a native toolchain is present. That made it possible to unbundle the Melange distribution into a few separate components.
Melange now ships with a melange.ppx
preprocessor based on Ppxlib that can be added to (preprocess (pps melange.ppx))
, as per Dune’s preprocessing specification.
The React JS PPX (for Reason + JSX) has also been extracted and is now distributed separately as reactjs-jsx-ppx
.
Enabling modern JS workflows
The Melange design in Dune was designed from day one with the goal of embracing the JavaScript platform:
The Dune integration generates JavaScript files in a predictable way
The resulting layout works well with the Node.js module resolution algorithm, which most bundlers understand.
The JS output layout is documented here.
To exercise modern workflows, Melange has been tested in a Next.js application using React Server Components, and the available constructs were deemed sufficient to enable similar use cases.
Full list of changes:
The full list of changes can be consulted here.
Support & Sponsorship
The effort that went into this release would not have been possible without the support of many.
We’d like to thank everyone who made it possible:
Ahrefs has shown interest in Melange since its first announcement. Since October 2022, Ahrefs’s crucial sponsorship has made it possible to build its codebase with Melange and work on this release.
Qwick, who has been running Melange since November 2022, providing invaluable feedback, financial backing and an open-minded team willing to try new directions.
The OCaml Software Foundation previously committed funding for the Melange project in October 2022, and has recently approved a new round of OSS sponsorship.
My (Antonio) sponsors on GitHub, both past and present
We’d also like to thank the following notable contributors to this release:
Rudi Grinberg, for his indispensable guidance and direction on the design and implementation of the Dune integration.
Javier Chávarri, for migrating a huge production codebase at Ahrefs to Melange, working on the Dune integration, the Melange documentation effort and providing vital feedback to the project.
David Sancho, for trying out our most bleeding edge ideas and providing early feedback on how to move forward with ways that encompass the whole ecosystem.
Looking Forward
We are enthusiastic about the progress we have made and the positive feedback we have received from the community. We remain committed to continuously improving Melange, ensuring it remains a robust and efficient tool for OCaml developers targeting the JavaScript platform.
Our Q2 2023 roadmap includes most of the goals that we set out to achieve over the past few months, and some of what we’re thinking about working in the months ahead. Melange 1.0 only marks the beginning of our journey towards the best OCaml experience on the JS platform.
Finally, we would like to extend our deepest thanks to everyone who has supported the project, whether through code contributions, testing, or providing feedback. This is your achievement as much as it is ours, and we look forward to continuing this journey together.
Thank you,
Antonio & The Melange Team
P.S.: If you are interested in trying out Melange, feel free to reply to this email. I’d love to hear from you!