Giter Club home page Giter Club logo

Comments (14)

xz64 avatar xz64 commented on July 20, 2024

I will take care of this in #14 as #14 has a dependency on producing license files this way.

from license-webpack-plugin.

xz64 avatar xz64 commented on July 20, 2024

@rhys-e I have implemented this functionality in the dev branch. Please try it out and let me know if you have any questions.

from license-webpack-plugin.

rhys-e avatar rhys-e commented on July 20, 2024

@xz64 Thanks - I've tried it out and it's working nicely except for two issues I'm noticing:

  1. Something's going wrong with the character encoding, e.g. double quotations are coming out in the license file as the string of the ASCII character (" => ")

  2. I've got 3 entry points in my webpack config. This results in 3 license files as expected however, only two license files contain the actual webpack license. All 3 outputted src files contain the webpack bootstrap, so I'd expect to see the webpack license in all 3 license files. I'm not sure why the 3rd entry point would be special in any way.

I've got a general question as well: what's your suggested strategy for bundling the project's license (i.e. not 3rdparty). To me it makes sense to also include this in the external license file to reduce impact on the outputted minified js, in which case it'd be helpful to have the plugin also pull in the project's license file.

Thanks

from license-webpack-plugin.

filipesilva avatar filipesilva commented on July 20, 2024

Heya @xz64, is it still possible to produce a single licenses file, or does it have to be one license file for each bundle?

from license-webpack-plugin.

xz64 avatar xz64 commented on July 20, 2024

@rhys-e I pushed a fix for the character encoding issue. Does your third entry reference any modules (via import/require statements) from node_modules?

Bundling the license of the project itself can be done with file-loader (basically copies your license file to your build output), but it will output the license to a separate file. I will consider adding an option to output first party license to each chunk later on.

@filipesilva The plugin won't be able to generate a single license file unless it relies on the 'done' phase of the webpack compiler. Relying on the 'done' phase however will bring up the issue you described in #14 . I might be able to rely on some sort of mkdirp functionality to work around that issue though.

from license-webpack-plugin.

rhys-e avatar rhys-e commented on July 20, 2024

@xz64 re: 3rd module - it does reference other things from node_modules

from license-webpack-plugin.

xz64 avatar xz64 commented on July 20, 2024

@rhys-e Can you share the webpack stats for your build? (If you are not sure how to generate the stats, please refer here: https://webpack.js.org/api/stats/ )

edit: Please be careful in sending the stats in case there is any sensitive data, as the stats will contain a lot of your own source code in it.

edit2: I noticed when I tried this on one of my own projects using ExtractTextWebpackPlugin, the 3rd party css libraries didn't get included. Is your third chunk a css chunk? If so, can you explain what css loaders/plugins you are using?

from license-webpack-plugin.

rhys-e avatar rhys-e commented on July 20, 2024

@xz64 quick note - If I do nothing in my code except import jquery then I get just the jquery license in the output, whereas if I import bowser I get both bowser's license and webpack's license. Both outputted bundles include the webpack bootstrapper as you'd expect.

Is adding the webpack license handled in some special way by the plugin? (since no-one has an import on webpack per se).

(My 3rd module isn't CSS, just a standard js module. I've boiled it down to a single file with a single import and seeing different behaviour depending on what I'm importing re: the inclusion of the webpack license or not).

from license-webpack-plugin.

xz64 avatar xz64 commented on July 20, 2024

@rhys-e I see now. I had misunderstood the issue. You are expecting the license for webpack itself to be included since webpack inserts its own module loading code into your bundle. I checked out the bowser package. It looks like bowser is using a UMD build which is causing webpack's amd "define" function stub ( node_modules/webpack/buildin/amd-define.js ) to be loaded.

The plugin has no special logic for webpack. It just goes by whatever webpack reports in the chunk info. Perhaps I can add an option to force certain packages to be included in every license output. Overall webpack is just bundling your dependencies together, so I don't see a strong reason for including the license for webpack itself into the build.

from license-webpack-plugin.

filipesilva avatar filipesilva commented on July 20, 2024

@xz64 I had a go at this change and wanted to mention it makes empty files for bundles with no licenses. I added a PR to fix that #17.

from license-webpack-plugin.

rhys-e avatar rhys-e commented on July 20, 2024

@xz64 I suspected it might be something along those lines. I would say though that in all cases webpack does leave a bit of code in the outputted bundle (the webpack bootstrap) which would be the case for including its license I guess.

from license-webpack-plugin.

xz64 avatar xz64 commented on July 20, 2024

@rhys-e I have made a change in the dev branch which allows you to force certain packages to be in the output. Please try it out and let me know how it goes.

from license-webpack-plugin.

xz64 avatar xz64 commented on July 20, 2024

Producing license file per chunk is is the default behavior in v1 now. (published now)

from license-webpack-plugin.

rhys-e avatar rhys-e commented on July 20, 2024

Tried out the additionalPackages flag, works fine 👍

from license-webpack-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.