-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rebuild project on package update (#2956) #3936
Conversation
{ persistent: false, recursive: true }, | ||
() => { | ||
clearTimeout(timeout); | ||
timeout = setTimeout(() => compiler.run(() => {}), 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.json
s inside it? and ignore some folders that would be changed on runtime like .cache
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.watch
has few problemsyarn add
of a missing moduleThis is my first dive into webpack related source.
❤️ for any pieces of advice.