kmagiera / babel-watch

Reload your babel-node app on JS source file changes. And do it fast.
MIT License
529 stars 70 forks source link

Update chokidar to improve atomic writes handling #101

Closed iiroj closed 5 years ago

iiroj commented 5 years ago

See link for more info: https://github.com/paulmillr/chokidar/issues/237#issuecomment-461729184

Chokidar had some issues with only detecting changes once per file. This seems to have been in fixed in version 2.1.3, and I tested that 2.1.5 works fine.

STRML commented 5 years ago

It's not technically necessary to update this as downstream users can simply delete the locked subdep, but given that the previous behavior causes some pretty weird problems (and few people actually know if they have atomic writes on - for example, ST3 supports it but does not use it by default) - I'm fine with merging this.

STRML commented 5 years ago

Thanks!

iiroj commented 5 years ago

For what it's worth, our initial fix was re-watching modified files in the handleChange function:

function handleChange(file) {
   watcher.unwatch(file);
   watcher.add(file);

  const absoluteFile = file.startsWith('/') ? file : path.join(cwd, file);
  delete cache[absoluteFile];
  delete errors[absoluteFile];

  // file is in use by the app, let's restart!
  debouncedRestartApp();
}