Skip to content

Commit d13222a

Browse files
committed
Moar migrate stuff
1 parent 1b1fe73 commit d13222a

File tree

1 file changed

+122
-1
lines changed

1 file changed

+122
-1
lines changed

pages/docs/manual/v12.0.0/migrate-to-v12.mdx

Lines changed: 122 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ canonical: "/docs/manual/v12.0.0/migrate-to-v12"
1414
- Uncurried mode must be enabled (i.e. you have not opted-out from it)
1515
- Your project must not contain any OCaml source code anymore, as support for `.ml` files is removed in this version. However there are ways to convert OCaml syntax with an older ReScript compiler version (see below).
1616
- The old configuration filename that was deprecated in v11, `bsconfig.json`, is removed. Rename it to `rescript.json`.
17+
- Minimum supported Node.js version is 20.0.0
1718

1819
### Standard library changes
1920

@@ -41,18 +42,108 @@ Also remove auto opening of `RescriptCore`.
4142
}
4243
```
4344

45+
if you had `@rescript/std` installed, remove it as well:
46+
47+
```shell
48+
npm uninstall @rescript/std
49+
```
50+
51+
this is replaced by `@rescript/runtime`, which is a installed as a dependency of `rescript` now.
52+
4453
## Replacements
4554

4655
Some typical name changes include:
4756

4857
`Error.t` -> `JsError.t`
49-
`raise(` -> `throw(`
58+
`raise(MyException("error"))` -> `throw(MyException("error"))`
5059
`Js.Exn.Error` exception -> `JsExn`
5160
`Error.make` -> `JsExn.make`
5261
`Error.raise` -> `JsExn.raise`
5362
`Error.message` -> `JsExn.message`
63+
`Bool.fromStringExn("true")` -> `Bool.fromStringOrThrow("true")`
5464
`Int.Bitwise.lsl` -> `Int.shiftLeft`
5565

66+
Tip: You can use the migration tool to automatically replace these with the new functions.
67+
68+
```shell
69+
npx rescript-tools migrate-all <root>
70+
71+
# preview the changes via
72+
rescript-tools migrate <file> [--stdout]
73+
```
74+
75+
### Bitwise operations
76+
77+
v11:
78+
79+
```res
80+
let x = ~a // bitwise NOT
81+
let y = a ^ b // bitwise XOR
82+
let z = a & b // bitwise AND
83+
let w = a | b // bitwise OR
84+
```
85+
86+
v12:
87+
88+
```res
89+
let x = ~~~a // bitwise NOT
90+
let y = a ^^^ b // bitwise XOR
91+
let z = a &&& b // bitwise AND
92+
let w = a ||| b // bitwise OR
93+
```
94+
95+
### JSX children spread
96+
97+
v11:
98+
99+
```res
100+
<div> ...children </div>
101+
```
102+
103+
v12:
104+
105+
```res
106+
<div> {...children} </div>
107+
```
108+
109+
### Attributes
110+
111+
v11:
112+
113+
```res
114+
@bs.as("foo")
115+
@bs.send
116+
@bs.new
117+
@raises
118+
@genType.as
119+
```
120+
121+
v12:
122+
123+
```res
124+
@as("foo")
125+
@send
126+
@new
127+
@throws
128+
@as
129+
```
130+
131+
- `@meth` and `@bs.send.pipe` are removed.
132+
133+
### Assert
134+
135+
v11:
136+
137+
```res
138+
assert 1 == 2
139+
```
140+
141+
v12:
142+
143+
```res
144+
assert(1 == 2) // Now a regular function call
145+
```
146+
56147
## Configuration
57148

58149
Rename `bsconfig.json` to `rescript.json` and update these configuration options:
@@ -65,3 +156,33 @@ Rename `bsconfig.json` to `rescript.json` and update these configuration options
65156

66157
- Set `version` to `4` (lower versions are not supported)
67158
- Remove `mode` option (automatically set to `automatic`)
159+
160+
## Build System Changes
161+
162+
The build system has been completely rewritten in v12.0.0.
163+
164+
In v11, we had:
165+
166+
```shell
167+
# build
168+
rescript build
169+
170+
# watch build
171+
rescript build -w
172+
173+
# format
174+
rescript format -all
175+
```
176+
177+
in v12, this becomes:
178+
179+
```shell
180+
# build
181+
rescript
182+
183+
# watch build
184+
rescript watch
185+
186+
# format
187+
rescript format
188+
```

0 commit comments

Comments
 (0)