npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rollup-plugin-oss

v0.3.1

Published

A rollup plugin to list dependency licenses and zip source files

Downloads

6

Readme

Rollup Plugin OSS

Rollup is a module bundler for JavaScript. It knows best which sourcecode it bundles.
This plugin hooks into the bundling step of rollup to

  • traces back the corresponding package.json of each bundled source file for (version, license and other) information
  • collects information of all used packages and adds them in a json (default disclosure.json) to the rollup bundle
  • zips all used source files, package.json and found license files, grouped by package, in a zip (default src.zip)

This also works with vite. The behavior is similiar to license-checker-webpack-plugin.

Please note that circular dependencies can occur in general, when bundling. For further discussion, see https://github.com/nodejs/readable-stream/issues/348

Usage

Install this package as development dependency

npm install -D rollup-plugin-oss

Add a rollup/vite config (e.g. rollup.config.js) to your project. Add filter to hide dependencies, add extra manually or adjust the output of the zip or json files.

import LicensePlugin from 'rollup-plugin-oss';
export default {
  input: 'src/main.js',
  output: {
    file: 'bundle.js',
    format: 'cjs'
  },
  plugins: [
    LicensePlugin({
      filter: /@mycompany\/.*/,
      extra: [{
        license: 'CC0-1.0',
        name: 'license-list-xml',
        repository: 'https://github.com/spdx/license-list-XML',
        version: '2.6.0',
        author: 'Linux Foundation and its Contributors',
        description: 'The SPDX License List is a list of commonly found licenses and exceptions used for open source and other collaborative software.  The XML format is an internal representation of the licenses.  See the license-list-data for supported formats for the license list.'
      }],
      zipFilename: 'src.zip',
      jsonFilename: 'disclosure.json'
    })
  ]
};

Test

Tests are run by jest against the outcome of the build process, i.e. index.js.

Example output

Get an example output for this library by running cloning the repository (with --recurse-submodules)

npm install
npm run build # prebuilds automatically
npm run bundle

or for pnpm

pnpm prebuild # trigger prebuild explicitly
pnpm build
pnpm bundle

In ./example folder, you'll get a disclosure.json file with:

{
  "libraries": [
    {
      "name": "tslib",
      "version": "2.4.0",
      "author": "Microsoft Corp.",
      "license": "0BSD",
      "licenseText": "Copyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.",
      "repository": "https://github.com/Microsoft/tslib",
      "description": "Runtime library for TypeScript helper functions"
    },
    ...
  ]
}

Accordingly, you'll find in src.zip:

user@host example % unzip src.zip
Archive:  src.zip
  inflating: [email protected]/package.json
  inflating: [email protected]/LICENSE.txt
  inflating: [email protected]/tslib.es6.js
  ...

License

MIT