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
+45Lines changed: 45 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,51 @@ As codebases grew, especially in monorepo setups with multiple packages, the old
33
33
34
34
These weren't just minor inconveniences. They were real productivity drains that got worse as projects scaled.
35
35
36
+
## Why a Complete Rewrite?
37
+
38
+
To understand why ReWatch represents such a significant improvement, it helps to understand what the old build system actually was.
39
+
40
+
### The Legacy Architecture: bsb + Ninja
41
+
42
+
The previous build system, bsb (BuckleScript Build), was actually a wrapper around Ninja, a generic build system originally created by Google for building Chrome. The workflow looked like this:
43
+
44
+
1. bsb scans your ReScript source files
45
+
2. Generates a `build.ninja` file describing all compilation rules
46
+
3. Ninja reads this file and executes the builds in parallel
47
+
4. Ninja tracks dependencies based on file timestamps
48
+
49
+
Ninja was chosen because it provided battle-tested parallelization out of the box. It worked well for getting ReScript off the ground. But there was a fundamental mismatch.
50
+
51
+
### The Impedance Mismatch
52
+
53
+
Ninja was designed for C++ compilation. It thinks in terms of files, timestamps, and simple command execution. It has no concept of modules, types, or interfaces.
54
+
55
+
ReScript compilation, however, needs to understand:
56
+
57
+
- Module interfaces versus implementations
58
+
- Type-level changes versus implementation changes
59
+
- Cross-module optimization opportunities
60
+
- Monorepo package boundaries
61
+
62
+
This mismatch meant that Ninja could only make decisions based on "file X changed, rebuild dependents." It couldn't look inside a module to see if only internal code changed. It had no awareness of ReScript's type system or module semantics.
63
+
64
+
Every ReScript-specific concept had to be translated into Ninja's generic model. This translation layer added complexity and, more importantly, limited what optimizations were possible. You can't do CMI hash checking when your build system doesn't know what a CMI file is.
65
+
66
+
### A Purpose-Built Solution
67
+
68
+
ReWatch is written specifically for ReScript, in Rust, with native understanding of ReScript's compilation model. There's no translation layer. The build system directly understands:
69
+
70
+
- ReScript's compilation phases (parsing, type checking, code generation)
71
+
- The meaning and role of CMI, CMT, and CMJ files
72
+
- Module dependency graphs and package boundaries
73
+
- When type changes require cascading rebuilds
74
+
75
+
This deep integration enables optimizations that were simply impossible with a generic build system. The CMI hash checking we'll discuss next is a perfect example: it requires the build system to understand what module interfaces are and how to detect when they've changed in meaningful ways.
76
+
77
+
Think of it this way: using Ninja for ReScript was like using a generic task runner for webpack's job. It works, but a tool designed specifically for the task can do things the generic tool never could.
78
+
79
+
The rewrite also opens doors for future improvements that require tight integration between the build system and the compiler: incremental type checking, distributed build caching, and better language server integration.
80
+
36
81
## The Intelligence Behind ReWatch
37
82
38
83
ReWatch takes a fundamentally different approach to building your code. At its core is a sophisticated understanding of what actually needs to be rebuilt when files change. Let's break down how it works.
0 commit comments