webpack: Watching symlinks doesn't work in dev mode
Bug report
What is the current behavior?
Watching symlinks doesn’t work after multiple changes in development mode.
If the current behavior is a bug, please provide the steps to reproduce.
webpack.config.js
module.exports = {
entry: './main.js',
watchOptions: { followSymlinks: true, },
mode: "development",
output: {
path: __dirname,
filename: 'bundle.js',
},
resolve: { symlinks: false }
};
main.js
Symlink to ./data/123.js
data/123.js
console.log("A");
Run
webpack --watch
echo 'console.log("B")' > main.js
echo 'console.log("C")' > main.js
What is the expected behavior?
I expected bundle.js to contain console.log("C")
, but it contained console.log("B")
.
Other relevant information:
webpack version: 5.65.0 Node.js version: 17.3.0 Operating System: Ubuntu 20.04 Additional tools:
Strangely, this example works fine in production mode.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 19 (9 by maintainers)
Commits related to this issue
- speed symlinks hot reload https://github.com/webpack/webpack/issues/15100 https://github.com/react-atomic/reshow/issues/70 — committed to react-atomic/reshow by HillLiu 2 years ago
@andreialecu, your issue is not related to this one. What you are describing is actually expected and working as intended.
node_modules
are considered immutable and only get invalidated once the version in package manifest changes.See https://github.com/angular/angular-cli/issues/22104 and https://github.com/angular/angular-cli/issues/20962
Hi @alan-agius4, I still think Angular 13, 14 does have this issue outside of node_modules and folders without a package.json inside them. We have a symlinked model folder that is shared between and Angular app and a NodeJs project. The folder is not in node_modules.
When we change a file. For example, adding a property to a class … Angular recompiles but complains that the class does not contain this new property. Killing the build and starting again resolves the issue but this is starting to become a massive drag on productivity.
Is there anyway to utilise any of the strategies above in the Angular.json or disable caching for a specific folder?
Regards, Tarek
Seems maybe this is solveable within webpack. To work around the issue, @pauldraper you can set
snapshot.module.hash = true
. to use hash of content instead of timestamp