JSON license report
At the end of every build, the plugin writes a JSON file describing each third-party dependency that made it into your bundle.
generateBundle → file§ Rollup plugin · v2.0.1
A Rollup plugin that turns your production bundle's dependency licenses into a clean, machine-readable JSON report — so open-source compliance doesn't become a manual task.
npm install -D @darcas/rollup-plugin-license-jsonRollup & Vite Zero runtime dependencies Node.js ≥ 14 TypeScript types included
§ 01 The problem
A modern JavaScript application pulls in a large dependency graph — direct packages, transitive packages, scoped packages you didn't even know were there.
Once everything is bundled, figuring out which third-party code and which licenses actually ended up in the distributed artifact means walking node_modules by hand: tedious, error-prone, and out of date the moment you ship again.
This plugin lives inside your build pipeline. It looks at what Rollup actually emits, not at what you think you installed, and turns it into a structured report — no separate compliance workflow to maintain.
§ 02 Features
The plugin does one job and does it natively: watch the bundle, collect license facts, emit JSON.
At the end of every build, the plugin writes a JSON file describing each third-party dependency that made it into your bundle.
generateBundle → fileOnly modules actually included in the output are traced back to their package.json — no guessing from your manifest.
renderChunk · renderedLength > 0Name, version, author, description, homepage, SPDX license and the full sanitized license text for every record.
LicensePluginJsonRecordRestrict dependencies to an SPDX expression like "(MIT OR Apache-2.0)", or plug in your own validator function.
spdx-expression-validate + spdx-satisfiesImplemented with native Rollup hooks, so it runs anywhere Rollup runs — including Vite. Zero runtime dependencies.
renderChunk + generateBundleInclude private packages or the project itself, keep every installed version, or enable debug logging of scanned modules.
includePrivate · includeSelf · multipleVersions§ 03 How it works
Your project runs its normal Rollup or Vite build. There is no separate step to remember.
For every module that made it into the rendered output, the plugin walks up the directory tree to its package.json and reads the license facts.
At bundle time, records are filtered (private, self), optionally validated against your SPDX allow-list, and written as JSON.
The report lands next to your artifact — archive it in CI, inspect it in review, or feed it to internal tooling.
§ 04 Usage
Pass the output path as the first argument — it is required and always wins. The optional second argument tunes what ends up in the report.
// rollup.config.mjsimport LicensePluginJson from '@darcas/rollup-plugin-license-json';export default { // ... plugins: [ // ... LicensePluginJson('./dist/licenses.json', { thirdParty: { allow: '(MIT OR Apache-2.0)', }, }), ],};§ 05 The output
One record per dependency, straight from each package's metadata and license file.
[ { "name": "axios", "version": "0.21.4", "author": { "name": "Matt Zabriskie", "email": null, "url": null }, "description": "Promise based HTTP client for the browser and node.js", "homepage": "https://axios-http.com/", "license": "MIT", "licenseText": "Permission is hereby granted, free of charge, to any person..." }, { "name": "lodash", "version": "4.17.21", "author": { "...": "..." }, "description": "A modern JavaScript utility library delivering modularity...", "homepage": "https://lodash.com/", "license": "MIT", "licenseText": "Permission is hereby granted, free of charge, to any person..." }]Records whose license text is empty or unavailable are omitted. HTML tags in license files are stripped; line breaks become <br> to preserve readability.
§ 06 Compliance
Instead of discovering third-party licenses after release, generate the information alongside the artifact — on every single build.
With thirdParty.allow, dependencies that violate your policy can warn — or stop the build entirely with failOnViolation / failOnUnlicensed.
Technical tooling helps you surface license information early. Your project's legal obligations should still be reviewed according to the licenses and policies that apply to it.
§ 07 FAQ
§ 08 Ecosystem
Install it once. Keep your dependency licensing information close to the artifact.