webpack / webpack

A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows for loading parts of the application on demand. Through "loaders", modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.
https://webpack.js.org
MIT License
64.26k stars 8.73k forks source link

the presence of the node_modules directory in the parent directory disables HMR for the my-app project. #18394

Closed yuhonyon closed 1 week ago

yuhonyon commented 3 weeks ago

Thank you for the clarification. It seems like you're encountering an issue with Webpack 5's new mechanism that disables hot module replacement (HMR) when there is a node_modules directory in the project path. While you understand that this is likely for performance optimization, you believe that the optimization should target node_modules within the project rather than simply disabling HMR whenever there is a node_modules directory in the path.

Your npm package is installed globally, and the installation path is /User/xxxx/xxxx/node_modules/my-app, which contains two node_modules directories: /xxxx/node_modules/xxx/my-app/node_modules. When you make updates to files within my-app, the presence of the node_modules directory in the parent directory disables HMR for the my-app project.

You're suggesting that instead of disabling HMR based solely on the presence of any node_modules directory in the path, Webpack should perhaps focus on optimizing node_modules within the project scope.

This issue might need to be reported to the Webpack team as a feature request or a bug report, suggesting a more refined approach to HMR optimization. You could provide this context along with your explanation to ensure clarity in your bug report or feature request.