Skip to content

Commit 4a9f35e

Browse files
committed
Format code
1 parent 2fe3c7e commit 4a9f35e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

_blogposts/2025-11-11-introducing-rewatch.mdx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ let defaultSize = Medium
7171
```
7272

7373
The `.cmi` file for this module will contain:
74+
7475
- The `size` type definition
7576
- The signature of `make`
7677
- The type of `defaultSize`
@@ -84,6 +85,7 @@ But it won't contain `internalHelper` because it's marked as [`%%private`](https
8485
ReWatch uses CMI files to make intelligent decisions about what needs recompiling. Here's how:
8586

8687
When you change a file, ReWatch:
88+
8789
1. Computes a hash of the current `.cmi` file (before compilation)
8890
2. Compiles the changed module
8991
3. Computes a hash of the new `.cmi` file (after compilation)
@@ -103,7 +105,7 @@ let make = (~size, ~onClick) => {
103105
let getClassName = (size) => {
104106
switch size {
105107
| Small => "btn-sm"
106-
| Medium => "btn-md"
108+
| Medium => "btn-md"
107109
| Large => "btn-lg"
108110
}
109111
}
@@ -127,12 +129,14 @@ let getClassName = (size) => {
127129
The internal implementation changed, but the public API (the `make` function signature) stayed the same. The `.cmi` file is identical before and after.
128130

129131
**With the old build system:**
132+
130133
- Button.res changes → recompile Button
131134
- Check all dependents of Button → recompile them too
132135
- Check all their dependents → recompile those as well
133136
- Result: potentially dozens of modules recompiled
134137

135138
**With ReWatch:**
139+
136140
- Button.res changes → recompile Button
137141
- Check Button.cmi hash → unchanged
138142
- Skip recompiling dependents
@@ -175,6 +179,7 @@ ReWatch employs another clever optimization for module resolution. When building
175179
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.
176180

177181
**Why this matters:**
182+
178183
- Module lookup becomes a single directory operation
179184
- The filesystem cache is more effective when files are adjacent
180185
- Cross-package references are as fast as local references
@@ -189,6 +194,7 @@ ReWatch compiles your modules in dependency-order waves, with parallel processin
189194
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.
190195

191196
Combined with the CMI hash checking, this means:
197+
192198
- Maximum parallelism within each wave
193199
- Waves can terminate early if interface stability is detected
194200
- No wasted work on modules that don't need rebuilding

0 commit comments

Comments
 (0)