Skip to content

Commit 35a9e30

Browse files
committed
fix: Avoid auto-reload for recently created source directory
Watchpack has a bug that caused it to dispatch change events for files that were created recently (up to 2 seconds before now). This can trigger an unwanted auto-reload, e.g. in the scenario of an extension developer building an extension and using `web-ext run` to immediately launch that built package.
1 parent e582e8f commit 35a9e30

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/watcher.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ export default function onSourceChange({
6363
files: watchedFiles,
6464
directories: watchedDirs,
6565
missing: [],
66-
startTime: Date.now(),
66+
// startTime: Date.now(), is explicitly NOT set because it causes onChange
67+
// to be emitted if the files were created shortly before now!
68+
// See https://github.com/webpack/watchpack/issues/295
6769
});
6870

6971
// TODO: support interrupting the watcher on Windows.

0 commit comments

Comments
 (0)