xz64 / license-webpack-plugin

Outputs licenses from 3rd party libraries to a file
ISC License
165 stars 51 forks source link

Some dependencies not being detected on Webpack 5 #91

Closed silverwind closed 3 years ago

silverwind commented 3 years ago

Not sure if this is really actionable but I noticed some modules are not being detected on Webpack 5 that were found on Webpack4:

First, there is vue and vue-loader, loaded via import Vue from 'vue' and for vue-loader in webpack config as loader for .vue files. Both are present on Webpack 4, absent on 5.

Secondly there are a lot of d3 dependencies missing, we import mermaid using await import('mermaid') which depends on d3 which depends on a whole lot of modules like d3-array and it's these modules that are all absent in 5 but were there in 4. Both mermaid and d3 are being detected fine.

xz64 commented 3 years ago

I think the root cause is webpack's optimizing away the context information about ES module imports, so LicenseWebpackPlugin doesn't know where the ES modules came from. I will see if I can add a hook to the parser to catch these imports.

xz64 commented 3 years ago

I fixed it by traversing the webpack stats instead. Please give it a try with v2.3.8 Thanks for your support

silverwind commented 3 years ago

Thanks, can confirm those d3 and vue packages now show up and the output looks very close to before.

Oh, and one more minor thing: Previously webpack itself was listed, but it seems gone currently. I guess it should be included because it has a small amount of runtime code for the lazy loading.

xz64 commented 3 years ago

Webpack reports its runtime differently in webpack v5. I have pushed a fix for that too. Try it out in v2.3.9

silverwind commented 3 years ago

Webpack is back in the output, thanks. Seems all my issues are resolved, thanks again.