§ Rollup plugin · v2.0.1

Know exactly which licenses ship with your bundle.

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-json

Rollup & Vite Zero runtime dependencies Node.js ≥ 14 TypeScript types included

licenses.jsonReport generated
The plugin writes a JSON array describing every bundled dependency, including its license and full license text.

Your bundle has dependencies. Your license report shouldn't be manual.

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.

Everything a build-time license report needs. Nothing else.

The plugin does one job and does it natively: watch the bundle, collect license facts, emit JSON.

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

Real dependency discovery

Only modules actually included in the output are traced back to their package.json — no guessing from your manifest.

renderChunk · renderedLength > 0

Full license metadata

Name, version, author, description, homepage, SPDX license and the full sanitized license text for every record.

LicensePluginJsonRecord

SPDX allow-list

Restrict dependencies to an SPDX expression like "(MIT OR Apache-2.0)", or plug in your own validator function.

spdx-expression-validate + spdx-satisfies

Rollup-native, Vite-compatible

Implemented with native Rollup hooks, so it runs anywhere Rollup runs — including Vite. Zero runtime dependencies.

renderChunk + generateBundle

Fine-grained control

Include private packages or the project itself, keep every installed version, or enable debug logging of scanned modules.

includePrivate · includeSelf · multipleVersions

From build output to license report, automatically.

  1. § 01

    Build

    Your project runs its normal Rollup or Vite build. There is no separate step to remember.

  2. § 02

    Inspect

    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.

  3. § 03

    Generate

    At bundle time, records are filtered (private, self), optionally validated against your SPDX allow-list, and written as JSON.

  4. § 04

    Ship

    The report lands next to your artifact — archive it in CI, inspect it in review, or feed it to internal tooling.

One plugin. A few lines of configuration.

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.

  • cwd — Project root used for "self" detection and package discovery. Defaults to process.cwd().
  • debug — Log every scanned module while the build runs.
  • thirdParty.allow — SPDX expression, validator function, or { test, failOnUnlicensed, failOnViolation }.
  • thirdParty.includePrivate — Include packages marked private in the report.
  • thirdParty.includeSelf — Include the project being built itself.
  • thirdParty.multipleVersions — Keep each installed version of a package instead of deduplicating by name.
rollup.config.mjs
// rollup.config.mjsimport LicensePluginJson from '@darcas/rollup-plugin-license-json';export default { // ... plugins: [ // ... LicensePluginJson('./dist/licenses.json', { thirdParty: { allow: '(MIT OR Apache-2.0)', }, }), ],};
The snippet above shows real options from the README — swap them for what your policy requires.

From dependency graph to structured data.

One record per dependency, straight from each package's metadata and license file.

dist/licenses.json
[ { "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..." }]
  • Archivable. The report is a plain JSON file — commit it, attach it to a release, or store it with the artifact.
  • Inspectable. Names, versions, authors and full license text are human-readable without extra tooling.
  • Processable. Typed as LicensePluginJsonRecord in TypeScript, trivially consumable by scripts.
  • CI/CD-ready. Because it is produced during the build, it is always in sync with what you actually ship.
LicensePluginJsonRecord = {
name, version: string
author: { name, email, url } | null
description, license, licenseText: string
homepage: string | null
}

Records whose license text is empty or unavailable are omitted. HTML tags in license files are stripped; line breaks become <br> to preserve readability.

Make license visibility part of your build.

Instead of discovering third-party licenses after release, generate the information alongside the artifact — on every single build.

  1. commit
  2. install dependencies
  3. rollup / vite build
  4. license report
  5. artifact · CI archive

With thirdParty.allow, dependencies that violate your policy can warn — or stop the build entirely with failOnViolation / failOnUnlicensed.

Questions, answered precisely.

Built for the tools you already use.

Rollupnative hooksViteworks out of the boxNode.js≥ 14.0.0TypeScripttypes included

Make license visibility part of every build.

Install it once. Keep your dependency licensing information close to the artifact.