rollup-license-plugin

raw JSON →
3.2.1 verified Mon Apr 27 auth: no javascript

Extracts OSS license information from npm packages used in Rollup or Vite builds, generating a bill of materials (JSON, HTML, CSV, etc.). Current stable version is 3.2.1 (March 2026), distributed as ESM-only with TypeScript types. Key differentiators: supports both Rollup and Vite, enforces license policies (fails builds on unacceptable licenses), excludes internal packages, and offers customizable output formats.

error Cannot find module 'rollup-license-plugin' or its corresponding type declarations.
cause Package is ESM-only but project uses CommonJS require()
fix
Use dynamic import: const { createRollupLicensePlugin } = await import('rollup-license-plugin');
error Error: 'createRollupLicensePlugin' is not a function
cause Incorrect import of default export (entire object)
fix
Use named import: import { createRollupLicensePlugin } from 'rollup-license-plugin';
error The plugin outputFilename is not a string
cause Output path must be a string, not an object or array
fix
Pass a string like 'third-party-licenses.json'
breaking v3 drops Node 16 support
fix Upgrade to Node 18+
breaking v3 is ESM-only, no CommonJS require()
fix Use import() or convert project to ESM
deprecated v2.x supported Node 14, v3 removes it
fix Use Node 18+
gotcha The plugin must be placed after other plugins that may transform or remove imports
fix Add the license plugin at the end of the plugins array
gotcha Output filename is relative to the build output directory
fix Use path.relative or absolute path if needed
gotcha License detection is based on node_modules metadata; works only for packages resolved by npm/yarn/pnpm
fix Ensure all dependencies are actually installed
npm install rollup-license-plugin
yarn add rollup-license-plugin
pnpm add rollup-license-plugin

Configures rollup-license-plugin in a Rollup config to generate a third-party notice JSON and fail the build on GPL/AGPL licenses.

// rollup.config.js
import { createRollupLicensePlugin } from 'rollup-license-plugin';

export default {
  input: 'src/index.js',
  output: { dir: 'dist', format: 'esm' },
  plugins: [
    createRollupLicensePlugin({
      outputFilename: 'thirdPartyNotices.json',
      // fail on GPL or AGPL licenses
      unacceptableLicenseTest: (licenseId) => /^(GPL|AGPL)/.test(licenseId),
      // exclude your own packages
      excludedPackageTest: (packageName) => packageName === '@mycompany/internal'
    })
  ]
};