niieani / webpack-dependency-suite

A set of Webpack plugins, loaders and utilities designed for advanced dependency resolution
MIT License
35 stars 5 forks source link

Globbing implementation #3

Open jods4 opened 7 years ago

jods4 commented 7 years ago

The globbing implementation in expandGlobBase is incorrect. I am not sure why you didn't use the glob module directly? It would reduce your code, be correct and support the full glob grammar.

Anyway, the most important problem in expandGlobBase is that it doesn't match /**/ for direct children. This is caused by your successive regexes that will turn pattern /**/ into the regex [\\/]+\.*?[\\/]+. Notice how this cannot be smaller than //, which is not what an empty path looks like.

niieani commented 7 years ago

The reason for not using the glob module is that it does not support passing a custom fs implementation. Webpack can use custom filesystems (like an in-memory filesystem) and thus abstracts out a custom fs implementation which is a subset of the native Node fs.

I'd be happy to merge a PR with the fix for this. Thanks for reviewing.

niieani commented 7 years ago

Note to self: use Minimatch to get a RegExp from the glob.