Repository navigation
watchOptions.ignored not working #1208
Description
Activity
@websolutions-hamburg thanks for the report, and good catch. I went all the way back through the blame and couldn't figure out when these options were ever used. this commit e7c5452 seems to have added the option. It would appear that these are supposed to be used with the
chokidarmodule, which WDS makes use of, but there are some discrepancies. I'll have to get with the team to chat about it and get back to you.Reacted by AdminOK so webpack proper is using an org module called watchpack, which is massaging the options before it's passed to chokidar https://github.com/webpack/watchpack/blob/ebcdc813100168af1a61189403a8b1abfa5338a3/lib/DirectoryWatcher.js#L58
That's a hold-over from before the project started using chokidar. So we're going to have to update the docs for WDS, and also do the same massaging of options here in WDS (in addition to actually passing the options to chokidar)
So there's some work to be done
watchOptions isn't ignoring anything at all. We have a file that is generated before compile time and its triggering another recompile unfortunately.
@jaunkst are you joining this issue to comment on a possibly-related issue, or the same symptoms in a different project? please remember it's best to be verbose.
watchOptions isn't ignoring anything at all.
in this context that's not actually true
@shellscape I have looked deeper and have discovered what our issue was, and how to work around it. I think its a combination of a few things.
- We are generating an entry file before we are kicking off the webpack-dev-server
- The watchpack has a 10s look behind on file changes and it is triggering the second build
- The watchOptions.ignore doesn't seem to allow us to ignore files that are entry items
We are currently having to backdate the file when its generated.
So I think the issue is with watchpacks 10s backdate window. The idea of ignoring a file that is added to webpacks entries does seem weird but in our case it is an autogenerated index.I was somewhat confused as to what was actually going on and assumed that somehow the ignored rule wasn't being applied.
Anyways, I never got the ignore rule to actually work in this particular case and I realize that in this issue it is when watching the baseContent for changes.
@jaunkst lots of solid info there. but I'm really confused - who is "we"? do you work with the original post author?
Reacted by Forrest, Dragan Filipović, Ben Grunfeld, amitrathi2124, snhwv, Jordan Thomson and Dom H@shellscape I do not work with the original author. I was referring to my team, sorry for the confusion.
@jaunkst thanks for clarifying. wanted to make sure I was addressing folks the right way here. Given your discoveries, I think it would be prudent to take this issue up with watchpack first, and webpack second. That is of course, if
watchOptionsis defined in yourwebpack.config.js. The other issue we have related to this issue is what I mentioned about thewatchOptionsnot being passed through tochokidarwithin webpack-dev-server (the commit I linked to) - and that has to be resolved as well.@shellscape yep, thats what I was thinking. I ended up logging the onChanges event in watchpack to see what files where triggering the recompile. It was the generated file and add adding it to the watchOptions.ignored did nothing. I even tried passing the options down to webpack-dev-servers watch options as you mentioned and it didn't help either. So I am assuming that because it is an entry it isn't being ignored or another watcher is being applied to the entries.
Waiting on CI to confirm the build and will publish when that's done running.
@jaunkst Google brings me here with the same problem as you.
I'm a webpack newbie so I'm not sure generating the file is the correct solution to the problem.
Could you add a comment to indicate where the discussion continues or how you solved it for future searchers?After much searching I found the problem to be webpack/watchpack#25 "Files created right before watching starts make watching go into a loop"
And solved it with https://github.com/egoist/time-fix-plugin
I solved it with
watchOptions:{
ignored: new RegExp("node_modules")
}
but with any format of string suggested in the manual it didn't workLinux Ubuntu 20.04.2
webpack 4.41.5
chokidar 3.5.2Reacted by Lith Hisham Ali, Alan.He, Mo Balaa, Jaroslav Bereza and 202 - Kévin GleizesReacted by François Billioud and Simen AndresenReacted by Amir Mohammad Moradi, 202 - Kévin Gleizes and David Fabreguette
Code
Expected Behavior
Ignore all
*.htmlfiles.Actual Behavior
Nothing will be ignored. I also checked the source code from webpack and webpack-dev-server and I didn't found a place where the configuration
watchOptions.ignoredwill be used.For Bugs; How can we reproduce the behavior?
Start the dev-server with option
watchContentBaseand try to ignore watch some files from the content base.