Skip to content

Commit 3606b7b

Browse files
authored
fix: rewatch not rebuilding on change (#7690)
* fix: listen to windows event * chore: CHANGELOG
1 parent b63b544 commit 3606b7b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#### :bug: Bug fix
3434

3535
- Fix `--create-sourcedirs` generation with for a single project. https://github.com/rescript-lang/rescript/pull/7671
36+
- Fix rewatch not recompiling on changes under windows. https://github.com/rescript-lang/rescript/pull/7690
3637

3738
# 12.0.0-beta.2
3839

rewatch/src/watcher.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,20 @@ async fn async_watch(
146146
) => {
147147
// if we are going to do a full compile, we don't need to bother marking
148148
// files dirty because we do a full scan anyway
149+
log::debug!("received {:?} while needs_compile_type was {needs_compile_type:?} -> full compile", event.kind);
149150
needs_compile_type = CompileType::Full;
150151
}
151152

152153
(
153154
CompileType::None | CompileType::Incremental,
154155
// when we have a data change event, we can do an incremental compile
155-
EventKind::Modify(ModifyKind::Data(_)),
156+
EventKind::Modify(ModifyKind::Data(_)) |
157+
// windows sends ModifyKind::Any on file content changes
158+
EventKind::Modify(ModifyKind::Any),
156159
) => {
157160
// if we are going to compile incrementally, we need to mark the exact files
158161
// dirty
162+
log::debug!("received {:?} while needs_compile_type was {needs_compile_type:?} -> incremental compile", event.kind);
159163
if let Ok(canonicalized_path_buf) = path_buf
160164
.canonicalize()
161165
.map(StrippedVerbatimPath::to_stripped_verbatim_path)
@@ -208,7 +212,6 @@ async fn async_watch(
208212
// these are not relevant events for compilation
209213
EventKind::Access(_)
210214
| EventKind::Other
211-
| EventKind::Modify(ModifyKind::Any)
212215
| EventKind::Modify(ModifyKind::Metadata(_))
213216
| EventKind::Modify(ModifyKind::Other),
214217
) => (),
@@ -217,6 +220,11 @@ async fn async_watch(
217220
}
218221
}
219222
}
223+
224+
if needs_compile_type != CompileType::None {
225+
log::debug!("doing {needs_compile_type:?}");
226+
}
227+
220228
match needs_compile_type {
221229
CompileType::Incremental => {
222230
let timing_total = Instant::now();
@@ -316,6 +324,9 @@ pub fn start(
316324

317325
let mut watcher = RecommendedWatcher::new(move |res| producer.push(res), Config::default())
318326
.expect("Could not create watcher");
327+
328+
log::debug!("watching {folder}");
329+
319330
watcher
320331
.watch(folder.as_ref(), RecursiveMode::Recursive)
321332
.expect("Could not start watcher");

0 commit comments

Comments
 (0)