From 885eee802116b3ac9aa3ba0bf92aa0ad114c107b Mon Sep 17 00:00:00 2001 From: Nathaniel Hill Date: Tue, 4 Sep 2018 10:20:10 -0500 Subject: [PATCH] Fix HMR when parent directory starts with '.' (#4589) @timneutkens This simple change seems to work for me: ``` const ignored = [ '**/.*', 'node_modules' ] ``` I believe the regex is used here to try and work on windows as well. So, I wasted a bunch of time trying to figure out how to use a regex and/or the `path` module to ignore the parent directories until I noticed the following: > glob patterns are not filepaths. They are a type of regular language that is converted to a JavaScript regular expression. Thus, when forward slashes are defined in a glob pattern, the resulting regular expression will match windows or POSIX path separators just fine. this is from the [anymatch](https://github.com/micromatch/anymatch) documentation which is what webpack uses accoring to this: https://webpack.js.org/configuration/watch/#watchoptions-ignored I've verified this glob pattern solves the problem in my environment, can someone test and verify that this works on windows? :+1: --- server/hot-reloader.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/hot-reloader.js b/server/hot-reloader.js index 9f9d06b3..20b9bced 100644 --- a/server/hot-reloader.js +++ b/server/hot-reloader.js @@ -292,8 +292,10 @@ export default class HotReloader { this.prevChunkHashes = chunkHashes }) + // We don’t watch .git .next/ and node_modules for changes const ignored = [ - /(^|[/\\])\../, // .dotfiles + /\.git/, + /\.next\//, /node_modules/ ]