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

Usage outside of Webpack #30

Open denis-sokolov opened 3 years ago

denis-sokolov commented 3 years ago

Would you consider an option to expose the use of this tool outside of the Webpack compilation? I am aware “webpack-plugin” is in the title, but webpack-specific code in this project is a very small part, just an API adapter, effectively. There’s still

My particular use case is to use it with an app built with Snowpack, but it could also be beneficial with any other way of building an app. There are existing 3rd-party tools, like license-checker, but there’s a lot to like about this particular one: the options, the generated notices file.

If you are open to the idea, I would consider making a small PR. I would start by adding two public functions validateLicenses(dependencies, options) and generateNotices(dependencies, options) at the top level as an alternative to the LicenseCheckerWebpackPlugin. Possibly a tiny CLI, too.

unindented commented 3 years ago

Actually, webpack is kind of important for generating the notice file. This tool generates the notice file based on the third-party dependencies that you're actually bundling, not based on your package(-lock).json. The stuff that you see in a package(-lock).json file doesn't really match what ends up being bundled and distributed to users. That's why the tool relies on webpack's compilation to generate it.

denis-sokolov commented 3 years ago

You’re completely right, I have misrepresented the relationship between this tool and the Webpack build process.

Nevertheless, I would still like to reiterate my suggestion/request. I don’t have Webpack, and I need to handle my own list of dependencies, but I would still benefit from using the rest of this tools for license validation and notice file generation.

Keavon commented 2 years ago

It looks like the industry is shifting away from Webpack and, in part, to Vite (among others). Especially in the Vue community (which my project uses). I'm sure it's not an easy task to change, but I also lend my vote that it would be fantastic to see this support Vite also, or something perhaps more generic/portable.

fhg-isi commented 1 year ago

Unfortunately, it does not seem to work with next.js. Also see simiarl issue at

https://github.com/codepunkt/webpack-license-plugin/issues/914