ReScript 11.0
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.:
SHnpm 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.
Highlights
Note: As this release is packed, please refer to the linked blogposts for a detailed breakdown of each of the main new features.
Customizable Variants
We are introducing new features that will improve interop with JavaScript/TypeScript, including customizable runtime representation of variants, zero cost bindings to discriminated unions, and unboxed variants that can be used to map to things like heterogenous array items and nullable values.
Enhanced Ergonomics for Record Types
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
First-class Dynamic Import Support
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
Uncurried Mode
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
New Standard Library: ReScript Core
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.
The latest docs on rescript-lang.org already use it for the examples. Have a look at the new RescriptCore API docs.
More Features
Furthermore, there are a lot of smaller improvements of which we want to state only a few here.
More types eligible for type coercion
The :>
(type coercion) operator now supports a few more datatypes, check out its Syntax Lookup page.
Build System
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.
rescript.json
The compiler config file has been renamed to rescript.json
. Since the rebrand from BuckleScript
to ReScript
, the bs-
names make no sense anymore. Later on, we will also rename some of the config attributes, like bs-dependencies
.
Relaxed Suffix Rules
You can now freely choose the suffix of the generated JS files. We recommend .res.js
/.res.mjs
which is also what our official templates in create-rescript-app
are using.
Opening files from current project globally
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:
JSON{
"bsc-flags": ["-open Utils"]
}
Ecosystem
Create-ReScript-App
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.
Going forward, 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.
ReScript-React v0.12
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.
ReScript Tools / Documentation Extraction
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:
SHnpm 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.
LSP
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:
SHnpm install -g @rescript/language-server npx rescript-language-server --stdio
What's next
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
remove
Belt
but 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
Acknowledgements
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.
That's it
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 (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
rescript-association/rescript-lang.org (documentation)