1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

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?

👍
This commit is contained in:
Nathaniel Hill 2018-09-04 10:20:10 -05:00 committed by Tim Neutkens
parent 64f3720e7f
commit 885eee8021

View file

@ -292,8 +292,10 @@ export default class HotReloader {
this.prevChunkHashes = chunkHashes
})
// We dont watch .git .next/ and node_modules for changes
const ignored = [
/(^|[/\\])\../, // .dotfiles
/\.git/,
/\.next\//,
/node_modules/
]