The ReScript developer experience now goes up to eleven!
Almost a year after the last release, ReScript is available in version 11! It marks the second major community-driven release and we are very thankful that there are so many willing contributors who invested their spare time into improving the compiler and its ecosystem.
Use your favorite package manager to install the new compiler release, e.g:
npm install rescript@11
To upgrade your project or to find out if there are any breaking changes that affect you, please follow the migration guide.
The complete list of changes can be found here. Let's have a look at the most notable improvements.
Note: As this release is packed, please refer to the linked blogposts for a detailed breakdown of each of the main new features.
New enhancements for record types: Record Type Spread and Record Type Coercion. Record Type Spread allows one to share subsets of record fields with other record types, making it easier to work with types with lots of fields. And Record Type Coercion makes it easier to safely to convert between records with the same set of fields (or a subset).
Blogpost: Enhanced Ergonomics for Record Types
Another addition is first-class support for dynamic imports, which will allow developers to split up and load parts of the app code on demand as separate JS modules to prevent bundle bloat and reduce initial load times for applications.
Blogpost: First-class Dynamic Import Support
This release is also introducing uncurried mode, which is a new default mode that compiles all dependencies as uncurried, and it aims to make it easier for newcomers to use the language.
Blogpost: Uncurried Mode
ReScript Core is ReScript's new standard library. It replaces the complete
Js module as well as some of the more frequently used modules from
Belt and is recommended to use with uncurried mode.
Furthermore, there are a lot of smaller improvements of which we want to state only a few here.
:> (type coercion) operator now supports a few more datatypes, check out its Syntax Lookup page.
The watcher can now be called with just
rescript -w. Also
rescript build will always build with dependencies by default so the argument
-with-deps is not needed anymore.
The compiler config file has been renamed to
rescript.json. Since the rebrand from
bs- names make no sense anymore. Later on, we will also rename some of the config attributes, like
You can now freely choose the suffix of the generated JS files. We recommend
.res.mjs which is also what our official templates in
create-rescript-app are using.
It's now possible to have a module opened by default that is just part of the current project. Previously, this only worked with dependencies or namespaced projects. For example, a file with the path
src/Utils.res can be added to
bsc-flags like so:
"bsc-flags": ["-open Utils"]
Previously, the ReScript binary was able to initialize new projects itself. But it was required to have a global npm install to use it. This functionality has been removed.
create-rescript-app is the new recommended way to setup a new project. It can even be used to quickly add ReScript to an existing project. Have a look at the updated installation instructions for how to use it.
In tandem with the new ReScript release, a new version of ReScript-React is released as well. It brings support for dynamically loading React components via
React.lazy, and more. Check out the corresponding docs.
There is a new experimental tool available that is a building block for documentation generation from ReScript files. It can be installed and used as follows:
npm install --save-dev @rescript/tools npx rescript-tools doc src/MyFile.res > doc.json
The tool generates a JSON structure with all the information you need to generate documentation automatically for your ReScript code. It also comes with ReScript bindings for that JSON. Shortly we'll also have automatic markdown generation, and we're planning a static site generator as well, so getting a nice looking and useful documentation site for your ReScript code is just a command away.
Our LSP powers our editor tooling. Historically, it has lived within the VSCode extension. This has been a problem for people who do not use VSCode. So, we've made sure that each new LSP version is published standalone to NPM.
This makes using an up-to-date version of the LSP in other editors than VSCode much easier. You can install and use it like so:
npm install -g @rescript/language-server npx rescript-language-server --stdio
As we now finish up the work on v11, we're looking forward to working on the next ReScript version. Here are some of the features we're planning to focus on in upcoming versions:
Make JSX usable beyond React:
Integrate the Rescript Core standard library into the compiler
remove the OCaml standard library
Beltbut keep it available as external package
Make maintaining TS libraries with ReScript a breeze, thanks to genType
Support tagged template literals
A new custom build system with better support for workspaces / monorepos
More improvements to the type system
We want to thank everyone from the community who volunteered their precious time to support this project with contributions of any kind, from documentation, to PRs, to discussions in the forum.
We hope you enjoy the newest improvements as much as we do.
In case of issues / problems, make sure to report bugs to one of the following repositories:
rescript-lang/rescript-compiler (language / syntax / jsx)
rescript-lang/rescript-react (React bindings)
rescript-lang/rescript-vscode (VSCode language support, LSP, tools)
rescript-lang/create-rescript-app (project generator) or