Skip to content

Commit 906c6c6

Browse files
committed
fix(watch-local-dependencies): Wait with add/change events until the entire file gets written
The watcher often copied zero-length files to the target path. The `awaitWriteFinish` option seems to be the good solution to handle this behavior, though it has its own drawbacks on the watcher performance (https://github.com/paulmillr/chokidar#performance)
1 parent 8ef6120 commit 906c6c6

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/project.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ async function watch_dependencies(packed_dependencies, { cwd, modules_path }) {
226226
const ignored_paths = (await Promise.all(globed_dependencies.map(({ local_package_path }) => get_ignore_rules(local_package_path)))).flat();
227227

228228
const watcher = chokidar.watch(files_to_watch, {
229+
awaitWriteFinish: true,
229230
// We compare the paths manually, because glob-patterns were not working on MacOS with folder-specific ignore rules (eg. `/tests`),
230231
// only if we explicitly set the rule to `/tests/**/*`. We could check each rule, whether it is a folder, and add `/**/*` respectively,
231232
// but that seems to be even more expensive. (Probably related to: https://github.com/paulmillr/chokidar/issues/773)

0 commit comments

Comments
 (0)