Skip to content

Commit 7947146

Browse files
committed
extend readme section on migration, and add a few more migration parts
1 parent ffbadb1 commit 7947146

File tree

2 files changed

+73
-1
lines changed

2 files changed

+73
-1
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,25 @@ _Things are added to this section on migration gradually._
144144

145145
Migrating to the new standard library should be easy to do gradually. In this section we'll gather information that's intended to help migrating as painlessly as possible.
146146

147+
In general, we suggest you take the following gradual approach:
148+
149+
1. Install the stdlib and open it in the global scope
150+
2. Fix any inconsistencies that uncovers. That will be things like module name clashes (more details below), `someArr[0]` now returning an option, and so on.
151+
3. Run the semi-automated migration below. This will uncover more things to fix.
152+
4. Do a final search for `Js.` in your project, and replace any leftovers that the migration script did not catch.
153+
154+
Check out [this issue on the GitHub tracker](https://github.com/rescript-association/rescript-core/issues/20) if you get stuck. We'll do what we can to help out when migrating there.
155+
147156
### Semi-automated migration
148157

149158
We've prepared a script you can run with [comby.dev](https://comby.dev) that will do parts of the migration for you automatically. The migration script is located in [`migration.toml`](migration/migration.toml). Here's an example of how you can run it:
150159

151160
```bash
152161
# Run in your project root. Assumes `migration.toml` has been copied in place to your project root.
153162
comby -config migration.toml -f .res -matcher .re -exclude-dir node_modules,__generated__ -i
163+
164+
# You should run it twice - once for .res files, and once for .resi. The command below runs for .resi, and the one above for .res.
165+
comby -config migration.toml -f .resi -matcher .re -exclude-dir node_modules,__generated__ -i
154166
```
155167

156168
The migration script is a set of instructions that Comby runs in sequence. You're encouraged to take `migration.toml` and tweak it so it fits your needs. [Comby](https://comby.dev) is powerful. It can do interactive rewriting and numerous other useful stuff. Check it out, but please note it's _not_ intended to cover all of the migration necessary. You'll still likely need to do a few manual fixes after running the migration scripts.

migration/migration.toml

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ rewrite="Dict.keysToArray"
8585
match="Js.Dict"
8686
rewrite="Dict"
8787

88+
[js-dict-t-z]
89+
match="Js.Dict.t"
90+
rewrite="Dict.t"
91+
8892
[js-nullable-z]
8993
match="Js.Nullable"
9094
rewrite="Nullable"
@@ -101,6 +105,50 @@ rewrite="Exn"
101105
match="Js.Re.test_"
102106
rewrite="RegExp.test"
103107

108+
[json-t-a]
109+
match="Js.Json.t"
110+
rewrite="JSON.t"
111+
112+
[json-t-rest]
113+
match="Js.Json"
114+
rewrite="JSON"
115+
116+
[float-a]
117+
match="Js.Float"
118+
rewrite="Float"
119+
120+
[int-a]
121+
match="Js.Int"
122+
rewrite="Int"
123+
124+
[math-a]
125+
match="Js.Math"
126+
rewrite="Math"
127+
128+
[math-a-a]
129+
match="Math.minMany_float"
130+
rewrite="Math.minMany"
131+
132+
[math-a-b]
133+
match="Math.maxMany_float"
134+
rewrite="Math.maxMany"
135+
136+
[math-a-c]
137+
match="Math.max_int"
138+
rewrite="Math.Int.max"
139+
140+
[math-a-d]
141+
match="Math.min_int"
142+
rewrite="Math.Int.min"
143+
144+
[math-a-e]
145+
match="Math.max_float"
146+
rewrite="Math.max"
147+
148+
[math-a-f]
149+
match="Math.min_float"
150+
rewrite="Math.min"
151+
104152
## BELT
105153
## Below are migrations that cover moving from Belt to equivalents
106154
## available in the new stdlib.
@@ -210,4 +258,16 @@ rewrite="(Int.fromString(~radix=10))"
210258

211259
[belt-int-z]
212260
match="Belt.Int"
213-
rewrite="Int"
261+
rewrite="Int"
262+
263+
[date-t-a]
264+
match="Js.Date.fromFloat"
265+
rewrite="Date.fromTime"
266+
267+
[date-t-rest]
268+
match="Js.Date"
269+
rewrite="Date"
270+
271+
[js-global-a]
272+
match="Js.Global."
273+
rewrite=""

0 commit comments

Comments
 (0)