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
watchpack watch not triggering when symlinked node_module files are modified when using webpack 'symlinks: true' #61
Comments
Yep, I'm seeing this exact problem with an angular 5 app and a linked node library I'm working on. Manually setting the flag works correctly. |
anyone looking for a horrifying stopgap waiting for this to be fixed, add |
same finding here, with same fix, for the same problem in opposite setup... bunch of symlinked files (under webpack + resolve.symlink=false) are not noticed for being changed.. because the actual links do not change. the followSymlinks:true fixes that. |
Me, another Angular 7 developer facing same problem. |
Experiencing this with 'symlinks: false' |
Finally I found this. Fix from @jukibom works! |
I'm also having this problem when I symlink a folder in my node_modules and use @jukibom workaround works for now. Thanks! |
Just in case @jukibom command doesn't work on your platform, you can install replace 'followSymlinks: false' 'followSymlinks: true' node_modules/watchpack/lib/DirectoryWatcher.js Its 100% analog to @jukibom solution, so all credits to him! |
var Module = require('module');
var originalRequire = Module.prototype.require;
Module.prototype.require = function () {
const original = originalRequire.apply(this, arguments);
if ("chokidar" === arguments[0]) {
var originalWatch = original.watch;
original.watch = function () {
const options = arguments[1];
if (options) {
options.followSymlinks = true;
}
return originalWatch.apply(this, arguments);
}
}
return original;
}; This piece of code should execute early, in the start script which ultimately launches webpack. In my case, I use https://github.com/gsoft-inc/craco, so I put it in |
In a regular webpack project, a symlinked module in node_modules is watched for changes correctly (as long as the module in question is referenced).
However, if using 'symlinks:true' in webpack to resolve symlinks to their full path (e.g. when using --preserve-symlinks behaviour in angular-cli), it does not seem to watch for changes anymore.
I have tracked this behaviour down to the 'followSymlinks' option of DirectoryWatcher in watchpack (https://github.com/webpack/watchpack/blob/master/lib/DirectoryWatcher.js). The followSymlinks option is always set to false which causes an issue with file watching when webpack is set to resolve symlinks. If it is manually set to true in this scenario, the watching works. Ideally this option would be configurable.
The text was updated successfully, but these errors were encountered: