{"id":22110,"library":"rollup-plugin-license","title":"rollup-plugin-license","description":"Rollup plugin that adds a license banner to the final bundle and generates a file listing all third-party licenses. Current stable version is 3.7.1, released with support for Rollup 4.x peer dependency. Key differentiators: supports multiple banner comment styles (regular, ignored, slash, none), file or string content with Lodash template interpolation, third-party license output with version deduplication, and custom data injection. Widely used for compliance in open-source and enterprise bundles. Ships TypeScript definitions. Maintained actively with regular updates.","status":"active","version":"3.7.1","language":"javascript","source_language":"en","source_url":"https://github.com/mjeanroy/rollup-plugin-license","tags":["javascript","rollup","rollup-plugin","typescript"],"install":[{"cmd":"npm install rollup-plugin-license","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-license","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-license","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin integrates into Rollup build pipeline","package":"rollup","optional":false}],"imports":[{"note":"This package is ESM-only; CommonJS require() will work in Node >=14 but the default export is a function. Use dynamic import() or ESM syntax in Rollup config.","wrong":"const license = require('rollup-plugin-license')","symbol":"license (default)","correct":"import license from 'rollup-plugin-license'"},{"note":"TypeScript types are bundled; use import type for options interface.","wrong":"","symbol":"license (type import)","correct":"import type { LicenseOptions } from 'rollup-plugin-license'"},{"note":"For .cjs config files, use dynamic import() to access the default export.","wrong":"const license = require('rollup-plugin-license')","symbol":"license (in CommonJS via .cjs)","correct":"const license = await import('rollup-plugin-license').then(m => m.default)"}],"quickstart":{"code":"// rollup.config.js (ESM)\nimport license from 'rollup-plugin-license'\nimport path from 'node:path'\n\nexport default {\n  input: 'src/main.js',\n  output: { file: 'dist/bundle.js', format: 'esm' },\n  plugins: [\n    license({\n      sourcemap: true,\n      banner: {\n        content: {\n          file: path.resolve('LICENSE'),\n          encoding: 'utf-8',\n        },\n      },\n      thirdParty: {\n        includePrivate: false,\n        includeSelf: true,\n        output: {\n          file: path.resolve('dist/dependencies.txt'),\n        },\n      },\n    }),\n  ],\n}","lang":"javascript","description":"Shows a minimal setup with banner from file and third-party license output."},"warnings":[{"fix":"Upgrade Node to >=14 and Rollup to ^1.0.0 or higher.","message":"Version 3.x dropped support for Node <14 and Rollup <1.x. The plugin now requires Rollup ^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use `thirdParty.dependencies` or `thirdParty.output`.","message":"The option `dependencies` in banner template data is deprecated since version 3.0.0. Use `thirdParty` options instead.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Set minifier option to preserve comments, e.g., terser({ format: { comments: 'all' } }).","message":"Using `commentStyle: 'ignored'` may not work in some minifiers (e.g., Terser) if they strip all comments by default. Ensure your minifier is configured to keep the banner.","severity":"gotcha","affected_versions":">=0.10.0"},{"fix":"Use `data` function to pass custom escaping or avoid template tags in banner.","message":"The banner content is processed as a Lodash template with `dependencies` array. If the template contains `<%` or `%>`, these must be escaped or the plugin will throw a lodash error.","severity":"gotcha","affected_versions":">=0.3.0"},{"fix":"If passing a string, use `banner: 'your string'` or `banner: { content: 'your string' }`.","message":"Version 0.10.0 changed `banner` from string to object with `content` and `commentStyle`. String usage still works but with deprecation warning.","severity":"breaking","affected_versions":">=0.10.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"npm install rollup-plugin-license --save-dev; in .cjs, use dynamic import: const license = await import('rollup-plugin-license').then(m => m.default)","cause":"Package not installed or ESM-only module imported via require() in CommonJS context.","error":"Error: Cannot find module 'rollup-plugin-license'"},{"fix":"Use default import: import license from 'rollup-plugin-license'","cause":"Importing the module incorrectly; likely using `require('rollup-plugin-license')` in ESM context.","error":"TypeError: license is not a function"},{"fix":"Use absolute path: path.resolve(__dirname, 'LICENSE')","cause":"The path provided in `banner.content.file` is relative and may not resolve correctly.","error":"Error: Banner file not found: 'LICENSE'"},{"fix":"Escape template tags: use `<%%` for literal `<%` or remove template syntax.","cause":"The banner contains invalid Lodash template syntax (e.g., unescaped `<%`).","error":"Error: Template execution failed: ..."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}