webpack.js.org
webpack.js.org copied to clipboard
`snapshot.managedPaths` and `snapshot.immutablePaths`
Feature to document
https://webpack.js.org/configuration/other-options/#immutablepaths https://webpack.js.org/configuration/other-options/#managedpaths
Could be a regexp with required capture group, which is path itself, e.g. defaults one https://github.com/webpack/webpack/blob/main/lib/config/defaults.js#L384
Author(s)
Additional information
[ ] I am willing to work on this issue and submit a pull request.
Please make sure this documentation includes why a capture group is needed because it seems unnecessary and confusing.
as I described it is path itself. e.g. in case
/^(.+?)[\\/]cache[\\/]watchpack-npm-[^\\/]+\.zip[\\/]node_modules[\\/]/
captured path will be (.+?)
But what does that even mean?
My best guess is that the capture group is meant to be the cache key for the folder but you can also have the regex match only certain files to be included as "managed" within it. But I'm just guessing because this isn't explained anywhere.
they described in docs.. both paths should point to directories. e.g. managesPaths ~~/.+?[\\/]node_modules[\\/]/~~ should be /(.+?[\\/]node_modules[\\/])/
Sorry, that still doesn't explain what the capture group is actually for. And that example doesn't have a capture group either!
I just checked the source code https://github.com/webpack/webpack/blob/2a58ce7883b42e1ebcfde617ec4a27c7feb035e6/lib/FileSystemInfo.js#L1997, capture group is required to work.
So I think the confusing part is why not just use a normal regexp to match paths in webpack source code?
Yes indeed, the capture group seems completely unnecessary.
- If is not needed then it should be removed as it's just confusing
- If it is needed then the docs need to explain why and give an example of when you would use it - an example that couldn't just be covered with a normal regex match
@SystemParadox I've tried to file a patch so we don't need the capture group.
But unfortunately this seems to be a breaking change. Maybe they can fix it in webpack v6 :)
Since #15969 has been closed "because it is required", can we please get this documented as to why it is required and what it does.
I've merged that pull request but will keep this issue open since it's valid concern in my opinion.