You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/docs/manual/latest/migrate-from-bucklescript-reason.mdx
+18-1Lines changed: 18 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -16,12 +16,29 @@ ReScript is a rebranding and cleanup of BuckleScript (since `v8.2.0`) & Reason (
16
16
There are lots of exciting improvements in the new syntax (features, speed, error messages, etc.). The upgrade is trivial, backward-compatible and can be done on a per-file basis:
17
17
18
18
- Upgrade your project to `bs-platform 8.2.0` or later.
- Choose a file to convert, for example `MyFile.re`
20
+
- Compile your project and keep the generated JavaScript file around (probably `MyFile.bs.js` but might depend on your `bsconfig.json` config).
21
+
- Run `node_modules/.bin/bsc -format MyFile.re > MyFile.res`.
22
+
- If your new `MyFile.res` looks good, you can delete (or move/rename) `MyFile.re` before compiling again your project (otherwise you will have an error `Invalid bsconfig.json implementation and interface have different path names or different cases MyFile vs MyFile` because 2 files with the same module name (file basename) cannot coexist in your project).
23
+
- Last thing you can do to ensure conversion is correct: build your project with the new `MyFile.res` file to compare the newly generated JavaScript file with the old one. You should get almost identical generated JavaScript code.
20
24
21
25
**That's it**! `MyFile.re` could be any `.re`, `.rei`, `.ml` and `.mli` file.
22
26
23
27
Enjoy the improved experience!
24
28
29
+
### Upgrade an Entire Folder
30
+
31
+
Please use this with caution. Migrating an entire codebase at once is an unnecessary risk.
32
+
It is recommended to migrate small portion of code to ensure correctness.
33
+
That being said, for small codebases or some tiny folders that are safely versioned, you can try the following:
34
+
35
+
```console
36
+
for f in your-folder/**/*.re; do; node_modules/.bin/bsc -format $f > ${f%.re}.res && rm $f; done;
37
+
```
38
+
39
+
This command loops on the `.re` files from the `your-folder` folder, converts them with a proper `.res` extension, and asks you if you want to remove the previous file (check the newly created `.res` file first and refer to instructions above to follow the check to do on your generated JavaScript).
40
+
If you are confident enough, you can add `-f` option to the `rm` command to avoid all checks. This will convert your entire folder without any confirmations.
41
+
25
42
## Difference With Old Reason
26
43
27
44
- Complete removal of semicolon (you can still write them).
0 commit comments