# rollup-plugin-oss

> A rollup plugin to list dependency licenses and zip source files

Latest version **0.4.0** (published 2026-04-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install rollup-plugin-oss
pnpm add rollup-plugin-oss
yarn add rollup-plugin-oss
bun add rollup-plugin-oss
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2026-04-29 |
| First published | 2022-06-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 4.8 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2 |
| Author | Axel Meinhardt |
| Maintainers | ameinhardt |
| Keywords | rollup, rollup-plugin, vite, vite-plugin, rolldown, license, oss |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-oss
- Repository: https://github.com/ameinhardt/rollup-plugin-oss
- Homepage: https://github.com/ameinhardt/rollup-plugin-oss#readme
- Issues: https://github.com/ameinhardt/rollup-plugin-oss/issues
- npm.io page: https://npm.io/package/rollup-plugin-oss

## Dependencies (2)

- [nearley](https://npm.io/package/nearley.md) ^2.20.1
- [zip-stream](https://npm.io/package/zip-stream.md) ^7.0.2

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.4.0 (latest) — 2026-04-29
- 0.3.2 — 2025-09-12
- 0.3.1 — 2023-07-11
- 0.3.0 — 2023-03-13
- 0.2.5 — 2022-11-12
- 0.2.4 — 2022-10-24
- 0.2.3 — 2022-10-24
- 0.2.2 — 2022-09-07
- 0.2.1 — 2022-06-27
- 0.2.0 — 2022-06-27
- 0.1.4 — 2022-06-24
- 0.1.3 — 2022-06-24

## README

# Rollup Plugin OSS

[Rollup](https://rollupjs.org/) 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
  * parses the `package.json` license field according to the [spdx license expression definition](https://spdx.dev/spdx-specification-21-web-version/#h.jxpfx0ykyb60)
  * aborts if ambiguous ("or" connected) license definition is found
  * records either a given license file or ammends the text based on [the related spdx license texts](https://github.com/spdx/license-list-data)
* 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](https://vitejs.dev/).
The behavior is similiar to [license-checker-webpack-plugin](https://github.com/microsoft/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
```bash
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.
```javascript
import LicensePlugin from 'rollup-plugin-oss';

export default {
  input: 'src/main.js',
  output: {
    file: 'bundle.js',
    format: 'cjs'
  },
  plugins: [
    LicensePlugin({
      extra: [{
        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.',
        license: 'CC0-1.0',
        name: 'license-list-xml',
        repository: 'https://github.com/spdx/license-list-XML',
        version: '2.6.0'
      }],
      filter: /@mycompany\/.*/,
      jsonFilename: 'disclosure.json',
      zipFilename: 'src.zip'
    })
  ]
};
```

## Test
Tests are run 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`)
```bash
npm install
npm run build # prebuilds automatically
npm run bundle
```
or for pnpm
``` bash
pnpm prebuild # trigger prebuild explicitly
pnpm build
pnpm bundle
```
In `./example` folder, you'll get a `disclosure.json` file with:
```json
{
  "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`:
```bash
user@host example % unzip src.zip
Archive:  src.zip
  inflating: tslib@2.4.0/package.json
  inflating: tslib@2.4.0/LICENSE.txt
  inflating: tslib@2.4.0/tslib.es6.js
  ...
```

## License
MIT

---
_Source: https://npm.io/package/rollup-plugin-oss · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
