Repository navigation
Conversation
| { persistent: false, recursive: true }, | ||
| () => { | ||
| clearTimeout(timeout); | ||
| timeout = setTimeout(() => compiler.run(() => {}), 1000); |
There was a problem hiding this comment.
In this approach, the fs.watch will be triggered, most likely, a lot of times on yarn add or yarn upgrade. Timeout here is to group these events and avoid rebuilding after a change of every file.
| } | ||
|
|
||
| apply(compiler) { | ||
| fs.watch( |
There was a problem hiding this comment.
why not use https://github.com/webpack/watchpack? also i think watching the whole files in node_modules would be very expensive, can we just watch all the package.jsons inside it? and ignore some folders that would be changed on runtime like .cache
There was a problem hiding this comment.
Hi, great to see you!
Webpack watch is current direction and changing a RegExp used to ignore node_modules.
There was a problem hiding this comment.
Hi, great to see you too!
Ah, I see, that would be better! would the ignored setting accept a function? I imagine it would be easier to read than a regex with lots of condition. Reading the docs it only accept regex or anymatch, but in some place like loaders' test it accept a function like (filePath) => filePath.endsWith('.js')
|
I'm experimenting with changing this watch ignore definition into Which, I checked in node REPL, should ignore all paths in node_modules except Still inspecting. (I started a friendship with Code Studio Node debugger to solve this puzzle) |
|
I think it's a bit weird that we have this problem in the first place. I distinctly remember webpack being able to pick up changes to the installed packages. What happened? |
|
We'll certainly use This happened. CRA has a webpack setup to ignore watching of node_modules. It was added to solve 293. |
|
Seems that webpack doesn't observe In scenario:
While server is running, any change in Confirmed this with debugger: At this point webpack has a list of files to watch in The observed files are calculated by visiting modules tree and collecting a list of files that are really used. |
|
What's next ... a) There is a PR to bring back watching node_modules on configurations where it would not cause a slowdown. |
|
Hey @maciej-ka! #3982 was created from some off-the-band discussions about the issues the For example CRA now supports monorepos so we should be able to handle multitudes of Would love if you reviewed #3982 and told me what you think about it ^^ |
|
3982 is so cool, because it would rebuild in both after adding and upgrading dependency. If I understand this: chokidar states that on both OSX and *nginx there will be no high CPU, however for the *nginx scenario it's advised to watch with a moderation. Webpack plugin to watch package.json using chokidar could be a fallback. I'll update this PR. |
Posting this to get early feedback.
My concerns are:
fs.watchhas few problemsyarn addof a missing moduleThis is my first dive into webpack related source.
❤️ for any pieces of advice.