{"id":21905,"library":"rollup-license-plugin","title":"rollup-license-plugin","description":"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.","status":"active","version":"3.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/codepunkt/rollup-license-plugin","tags":["javascript","rollup","vite","build","artifact","oss","open source","compliance","copyright","typescript"],"install":[{"cmd":"npm install rollup-license-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-license-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-license-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for Rollup plugin integration","package":"rollup","optional":true},{"reason":"peer dependency for Vite plugin integration","package":"vite","optional":true}],"imports":[{"note":"ESM-only since v3. Use dynamic import() for CommonJS.","wrong":"const createRollupLicensePlugin = require('rollup-license-plugin')","symbol":"createRollupLicensePlugin","correct":"import { createRollupLicensePlugin } from 'rollup-license-plugin'"},{"note":"Same as createRollupLicensePlugin but for Vite.","wrong":"import { createViteLicensePlugin } from 'rollup-license-plugin' (none)","symbol":"createViteLicensePlugin","correct":"import { createViteLicensePlugin } from 'rollup-license-plugin'"},{"note":"TypeScript type import only; not a runtime value.","wrong":"import { PluginOptions } from 'rollup-license-plugin' (value import)","symbol":"PluginOptions","correct":"import type { PluginOptions } from 'rollup-license-plugin'"},{"note":"Default export is an object { createRollupLicensePlugin, createViteLicensePlugin }. Avoid require() for default.","wrong":"const rollupLicensePlugin = require('rollup-license-plugin').default","symbol":"default","correct":"import rollupLicensePlugin from 'rollup-license-plugin'"}],"quickstart":{"code":"// rollup.config.js\nimport { createRollupLicensePlugin } from 'rollup-license-plugin';\n\nexport default {\n  input: 'src/index.js',\n  output: { dir: 'dist', format: 'esm' },\n  plugins: [\n    createRollupLicensePlugin({\n      outputFilename: 'thirdPartyNotices.json',\n      // fail on GPL or AGPL licenses\n      unacceptableLicenseTest: (licenseId) => /^(GPL|AGPL)/.test(licenseId),\n      // exclude your own packages\n      excludedPackageTest: (packageName) => packageName === '@mycompany/internal'\n    })\n  ]\n};","lang":"typescript","description":"Configures rollup-license-plugin in a Rollup config to generate a third-party notice JSON and fail the build on GPL/AGPL licenses."},"warnings":[{"fix":"Upgrade to Node 18+","message":"v3 drops Node 16 support","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use import() or convert project to ESM","message":"v3 is ESM-only, no CommonJS require()","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use Node 18+","message":"v2.x supported Node 14, v3 removes it","severity":"deprecated","affected_versions":">=3.0.0 <4.0.0"},{"fix":"Add the license plugin at the end of the plugins array","message":"The plugin must be placed after other plugins that may transform or remove imports","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use path.relative or absolute path if needed","message":"Output filename is relative to the build output directory","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Ensure all dependencies are actually installed","message":"License detection is based on node_modules metadata; works only for packages resolved by npm/yarn/pnpm","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use dynamic import: const { createRollupLicensePlugin } = await import('rollup-license-plugin');","cause":"Package is ESM-only but project uses CommonJS require()","error":"Cannot find module 'rollup-license-plugin' or its corresponding type declarations."},{"fix":"Use named import: import { createRollupLicensePlugin } from 'rollup-license-plugin';","cause":"Incorrect import of default export (entire object)","error":"Error: 'createRollupLicensePlugin' is not a function"},{"fix":"Pass a string like 'third-party-licenses.json'","cause":"Output path must be a string, not an object or array","error":"The plugin outputFilename is not a string"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}