microsoft / license-checker-webpack-plugin

Webpack plugin that verifies licenses of all external dependencies in a compilation, and outputs them to a file.
MIT License
135 stars 28 forks source link

Filter scoped modules correctly #37

Open bz2 opened 3 years ago

bz2 commented 3 years ago

Fixes microsoft/license-checker-webpack-plugin#25

A valid node module name is either \w+ or @\w+/\w+ never @\w+.

This is enough of a hairy internal implementation detail that filter should probably not be exposed even as an (undocumented) option. But leaving alone for now as changing the pattern has been a useful workaround.

There are some other implications from the webpack 5 changes to fileDependencies and the current code behaviours but those will need a bit more discussion to address I think.

Eli-Black-Work commented 3 years ago

Thank you so much for this!! 🙂

FYI, I think the tests will break when using Yarn PnP, since then there won't be a node_modules folder.

felixfontein commented 2 years ago

This fixes the problems described in #45 and #43 for me. If anyone else cares, this PR can also be used as a workaround by adding the filter definition from it into your LicenseCheckerWebpackPlugin options, like this:

    new LicenseCheckerWebpackPlugin({
      allow: "(Apache-2.0 OR BSD-2-Clause OR BSD-3-Clause OR MIT OR 0BSD)",
      filter: /(^.*[/\\]node_modules[/\\]((?:@[^/\\]+[/\\])?(?:[^@/\\][^/\\]*)))/,
      ...

Would still be better if this could be merged and released :)

domis4 commented 2 years ago

anychance microsoft will actually review this?

bz2 commented 2 years ago

Part of the issue may the that the maintainer now works at twitter not ms. Maybe @unindented could suggest a former colleague I could bug about taking over package?

bz2 commented 2 years ago

Part of the issue may the that the maintainer now works at twitter not ms. Maybe @unindented could suggest a former colleague I could bug about taking over package?

stritti commented 1 year ago

Have same issue with vuejs:

 ERROR  HookWebpackError: Cannot find module 'node_modules\@vue/package.json'
        Require stack:
        - node_modules\license-checker-webpack-plugin\src\licenseUtils.js
        - node_modules\license-checker-webpack-plugin\src\index.js
        - vue.config.js
        - package.json