darrenscerri / duplicate-package-checker-webpack-plugin

🕵️ Webpack plugin that warns you when a build contains multiple versions of the same package
MIT License
707 stars 29 forks source link

Ignore dependencies coming from webpack-dev-server #11

Closed sandersky closed 6 years ago

sandersky commented 7 years ago

This plugin currently informs me of duplicates where one of the instances comes from webpack-dev-server. Ideally it'd be nice if this plugin simply ignores files from that module to reduce noise, or potentially even provides an optional function for consumers to identify whatever they deem a false positive. Maybe something like:

new DuplicatePackageCheckerPlugin({
  emitError: false,
  isFalsePositive: function () {
    // add custom logic here that returns true when we deem this is a false positive.
    // this will require useful information via argument(s) for custom logic
    return false;
  },
  verbose: true,
})
darrenscerri commented 7 years ago

Thanks for opening this issue @sandersky. What kind of arguments do you have in mind? I'm currently thinking about adding the package name and full path of the module. Is there something else that you think might be useful?

sandersky commented 7 years ago

Glancing at the code real quick what about instances and name which come from here? Your logic could just do an early return in the for loop whenever the custom method returns true to avoid logging the issue or pushing an error to the array.