'should changes in node_modules invalidate the webpack build cache?

Webpack config cache.buildDependencies can be used to list files or directories, such that if they change then the filesystem-based webpack build cache is invalidated.

This is documented in depth at the persistent caching guide.

The doc says the webpack lib is included by default. Doc also shows how to include the webpack.config.js file itself.

Is it a stupid question to ask, how about node_modules? They don't mention anything like yarn.lock either. In some kinds of workspaces lib dependencies may appear in node_modules as symlinks - in those cases the dependency can be updated in parallel during development. Those changes should invalidate these webpack build caches right?



Solution 1:[1]

Had the same issue with changes in packages linked with npm link not appearing even though both apps were rebuilt. Adding this to my webpack.config fixed it, but please don't ask me why exactly - docs are not super detailed on snapshot:

snapshot: {
        managedPaths: [/^(.+?[\\/]node_modules)[\\/]((?!your-modules)).*[\\/]*/],
    },

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 suuuriam