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: _blogposts/2025-11-11-introducing-rewatch.mdx
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,6 +71,7 @@ let defaultSize = Medium
71
71
```
72
72
73
73
The `.cmi` file for this module will contain:
74
+
74
75
- The `size` type definition
75
76
- The signature of `make`
76
77
- The type of `defaultSize`
@@ -84,6 +85,7 @@ But it won't contain `internalHelper` because it's marked as [`%%private`](https
84
85
ReWatch uses CMI files to make intelligent decisions about what needs recompiling. Here's how:
85
86
86
87
When you change a file, ReWatch:
88
+
87
89
1. Computes a hash of the current `.cmi` file (before compilation)
88
90
2. Compiles the changed module
89
91
3. Computes a hash of the new `.cmi` file (after compilation)
@@ -103,7 +105,7 @@ let make = (~size, ~onClick) => {
103
105
let getClassName = (size) => {
104
106
switch size {
105
107
| Small => "btn-sm"
106
-
| Medium => "btn-md"
108
+
| Medium => "btn-md"
107
109
| Large => "btn-lg"
108
110
}
109
111
}
@@ -127,12 +129,14 @@ let getClassName = (size) => {
127
129
The internal implementation changed, but the public API (the `make` function signature) stayed the same. The `.cmi` file is identical before and after.
128
130
129
131
**With the old build system:**
132
+
130
133
- Button.res changes → recompile Button
131
134
- Check all dependents of Button → recompile them too
132
135
- Check all their dependents → recompile those as well
133
136
- Result: potentially dozens of modules recompiled
134
137
135
138
**With ReWatch:**
139
+
136
140
- Button.res changes → recompile Button
137
141
- Check Button.cmi hash → unchanged
138
142
- Skip recompiling dependents
@@ -175,6 +179,7 @@ ReWatch employs another clever optimization for module resolution. When building
175
179
Think of it like organizing a library. The old approach was like having books scattered across multiple rooms and floors. To find a specific book, you'd need to check each room. ReWatch's approach is like putting all the books in one room. Finding what you need is instant.
176
180
177
181
**Why this matters:**
182
+
178
183
- Module lookup becomes a single directory operation
179
184
- The filesystem cache is more effective when files are adjacent
180
185
- Cross-package references are as fast as local references
@@ -189,6 +194,7 @@ ReWatch compiles your modules in dependency-order waves, with parallel processin
189
194
Here's how it works: modules with no pending dependencies compile first, in parallel. As they complete, the next wave of modules (whose dependencies are now satisfied) begins compiling. This continues until all modules are built.
190
195
191
196
Combined with the CMI hash checking, this means:
197
+
192
198
- Maximum parallelism within each wave
193
199
- Waves can terminate early if interface stability is detected
194
200
- No wasted work on modules that don't need rebuilding
0 commit comments