Webpack: Support Ignore Plugin
eoingroat opened this issue · 3 comments
I've recently been using pahen/madge
to show dependency graphs (and explain circular dependencies), for my webpack codebase. pahen/madge
depends on this module. In tracing why dependencies are showing on the graph that shouldn't be there, it has come to light that node-filing-cabinet
only checks the resolve
field in webpackConfig
despite resolution issues being affected by plugin fields.
In my case I use the canonical IgnorePlugin to exclude certain files from certain builds.
I doubt it is feasible to process every plugin, but it would be very useful to support the built in webpack plugin "IgnorePlugin".
Hey @eoingroat. Thanks for filing the issue!
This is a tricky one. The fact that modules are showing up in the dependency graph means that there are real dependencies about those files. Saying that you want to ignore them from a webpack build is different than saying real dependencies shouldn't be in the dependency graph.
Do you have an idea of how you'd support the ignorePlugin here? We rely on webpack's enhanced-resolve module to do all webpack resolution: https://github.com/webpack/enhanced-resolve#enhanced-resolve. Is there a way to supply config and register plugins to support the ignorePlugin? I'd be open to a PR that provides support for it.
Thanks!
I've played around a bit with enhanced-resolve, and it seems it's a weakness in the way webpack is defined that the IgnorePlugin is part of the main plugin system and not the resolver system; I'll look at raising an issue over there for a long term fix (and perhaps making a PR for a change to IgnorePlugin itself)
Unfortunately it explicitly breaks the expectation of this module, as the dependencies returned by a given config are not the same as the dependencies that exist when using it (it is also possible to insert dependencies with such plugins).
After consideration I think this is an issue that probably can't be fixed here, but is a problem with one of the dependencies! :(
Thank you for your help.
Thanks @eoingroat!