Skip to content

Commit b3f9c15

Browse files
Some improvements to the v11 migration guide
1 parent 48bbca5 commit b3f9c15

File tree

4 files changed

+116
-74
lines changed

4 files changed

+116
-74
lines changed

data/sidebar_manual_latest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"Overview": [
33
"introduction",
44
"installation",
5-
"migrate-to-v11-and-uncurried-mode",
5+
"migrate-to-v11",
66
"editor-plugins",
77
"try"
88
],

next.config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ const config = {
102102
destination: "/docs/manual/v10.0.0/unboxed",
103103
permanent: true,
104104
},
105+
{
106+
source: "/docs/manual/latest/migrate-to-v11-and-uncurried-mode",
107+
destination: "/docs/manual/latest/migrate-to-v11",
108+
permanent: true,
109+
},
105110
];
106111
},
107112
};

pages/docs/manual/latest/migrate-to-v11-and-uncurried-mode.mdx

Lines changed: 0 additions & 73 deletions
This file was deleted.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
---
2+
title: "Migrate to v11"
3+
description: "Instructions on upgrading to ReScript 11 with the new uncurried mode"
4+
canonical: "/docs/manual/latest/migrate-to-v11"
5+
---
6+
7+
# Migrate to ReScript 11
8+
9+
## Minimal Migration
10+
11+
This guide describes the things to do at least to migrate to ReScript 11.
12+
13+
### Disable uncurried mode
14+
15+
If you use currying extensively and don't want to bother with adapting your code (or have dependencies )
16+
17+
```json
18+
{
19+
"uncurried": false
20+
}
21+
```
22+
23+
## Recommended Migration
24+
25+
### Uncurried Mode
26+
27+
For uncurried mode to take effect in ReScript 11 there is nothing to configure, it is activated by default.
28+
29+
### Adapt suffix
30+
31+
ReScript 11 now allows having arbitrary suffixes in the generated JavaScript files. However it is still recommended to stick to using `.res.js`, `.res.mjs` or `.res.cjs`. For more information, read the Build System Configuration about [suffixes](/docs/manual/latest/build-configuration#suffix).
32+
33+
### rescript.json
34+
35+
The old configuration filename `bsconfig.json` is finally deprecated. Rename it to `rescript.json`.
36+
37+
### ReScript Core standard library
38+
39+
There is a new standard library in development that can already be installed called ReScript Core. It replaces the complete `Js` module as well as some of the more frequently used modules from `Belt` and is the recommended standard library to use with uncurried mode. At a later stage it will be integrated into the compiler while `Belt` will be maintaned as a separate npm package.
40+
41+
Until it's integrated in the compiler, it needs to be installed manually:
42+
43+
```console
44+
$ npm install @rescript/core
45+
```
46+
47+
Then add `@rescript/core` to your `rescript.json`'s dependencies:
48+
49+
```diff
50+
{
51+
"bs-dependencies": [
52+
+ "@rescript/core"
53+
]
54+
}
55+
```
56+
57+
Open it so it's available in the global scope.
58+
59+
```diff
60+
{
61+
"bsc-flags": [
62+
+ "-open RescriptCore",
63+
]
64+
}
65+
```
66+
67+
For a detailed explanation on migration to ReScript Core, please refer to its [migration guide](https://github.com/rescript-association/rescript-core#migration). A semi-automated script is available as well.
68+
69+
**Note**: ReScript Core API docs will be added to this documentation platform at a later stage. For now check out the `.resi` files in the repository or, more conveniently, read the docs for a certain module or function directly in the editor tooling.
70+
71+
### Removed bindings
72+
73+
Many Node bindings have been removed from the compiler. Please use [rescript-nodejs](https://github.com/TheSpyder/rescript-nodejs) instead or write your own local bindings.
74+
75+
## List of all breaking changes
76+
77+
Below is an excerpt from the compiler changelog about all the breaking changes of ReScript 11.
78+
79+
### Language and Compiler
80+
81+
- Add smart printer for pipe chains. https://github.com/rescript-lang/rescript-compiler/pull/6411 (the formatter will reformat existing code in certain cases)
82+
- Parse `assert` as a regular function. `assert` is no longer a unary expression. Example: before `assert 1 == 2` is parsed as `(assert 1) == 2`, now it is parsed as `assert(1 == 2)`. https://github.com/rescript-lang/rescript-compiler/pull/6180
83+
- Remove support for the legacy Reason syntax. Existing Reason code can be converted to ReScript syntax using ReScript 9 as follows:
84+
- `npm i -g rescript@9`
85+
- `rescript convert <reason files>`
86+
- Curried after uncurried is not fused anymore: `(. x) => y => 3` is not equivalent to `(. x, y) => 3` anymore. It's instead equivalent to `(. x) => { y => 3 }`.
87+
Also, `(. int) => string => bool` is not equivalen to `(. int, string) => bool` anymore.
88+
These are only breaking changes for unformatted code.
89+
- Exponentiation operator `**` is now right-associative. `2. ** 3. ** 2.` now compile to `Math.pow(2, Math.pow(3, 2))` and not anymore `Math.pow(Math.pow(2, 3), 2)`. Parentheses can be used to change precedence.
90+
- Stop mangling object field names. If you had objects with field names containing "\__" or leading "_", they won't be mangled in the compiled JavaScript and represented as it is without changes. https://github.com/rescript-lang/rescript-compiler/pull/6354
91+
- `$$default` is no longer exported from the generated JavaScript when using default exports. https://github.com/rescript-lang/rescript-compiler/pull/6328
92+
- `-bs-super-errors` flag has been deprecated along with Super_errors. https://github.com/rescript-lang/rescript-compiler/pull/6243
93+
- Remove unsafe `` j`$(a)$(b)` `` interpolation deprecated in compiler version 10 https://github.com/rescript-lang/rescript-compiler/pull/6068
94+
- `@deriving(jsConverter)` not supported anymore for variant types https://github.com/rescript-lang/rescript-compiler/pull/6088
95+
- New representation for variants, where the tag is a string instead of a number. https://github.com/rescript-lang/rescript-compiler/pull/6088
96+
97+
### Compiler Libraries
98+
99+
- Fixed name collision between the newly defined Js.Json.t and the variant constructor in the existing Js.Json.kind type. To address this, the usage of the existing Js.Json.kind type can be updated to Js.Json.Kind.t. https://github.com/rescript-lang/rescript-compiler/pull/6317
100+
- Remove rudimentary node bindings and undocumented `%node` extension. https://github.com/rescript-lang/rescript-compiler/pull/6285
101+
- `@rescript/react` >= 0.12.0-alpha.2 is now required because of the React.fragment's children type fix. https://github.com/rescript-lang/rescript-compiler/pull/6238
102+
- Remove deprecated module `Printexc`
103+
104+
### Build System and Tools
105+
106+
- Update watcher rules to recompile only on config and `*.res`/`*.resi`/`*.ml`/`.mli` file changes. Solves the issue of unnecessary recompiles on `.css`, `.ts`, and other unrelated file changes. https://github.com/rescript-lang/rescript-compiler/pull/6420
107+
- Made pinned dependencies transitive: if _a_ is a pinned dependency of _b_ and _b_ is a pinned dependency of _c_, then _a_ is implicitly a pinned dependency of _c_. This change is only breaking if your build process assumes non-transitivity.
108+
- Remove obsolete built-in project templates and the "rescript init" functionality. This is replaced by [create-rescript-app](https://github.com/rescript-lang/create-rescript-app) which is maintained separately.
109+
- Do not attempt to build ReScript from source on npm postinstall for platforms without prebuilt binaries anymore.
110+
- GenType: removed support for `@genType.as` for records and variants which has become unnecessary. Use the language's `@as` instead to channge the runtime representation without requiring any runtime conversion during FFI. https://github.com/rescript-lang/rescript-compiler/pull/6099 https://github.com/rescript-lang/rescript-compiler/pull/6101

0 commit comments

Comments
 (0)