Gathering detailed insights and metrics for rollup-plugin-license
NPM registry records approximately 1.5 to 2 billion package downloads per day.
Gathering detailed insights and metrics for rollup-plugin-license
NPM registry records approximately 1.5 to 2 billion package downloads per day.
npm install rollup-plugin-license
57.1
Supply Chain
98.3
Quality
83
Maintenance
100
Vulnerability
98.6
License
114 Stars
2,461 Commits
21 Forks
3 Watching
10 Branches
14 Contributors
Updated on 20 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-9.5%
17,203
Compared to previous day
Last week
1.1%
102,997
Compared to previous week
Last month
38.7%
392,483
Compared to previous month
Last year
125.4%
3,319,770
Compared to previous year
8
1
29
Rollup plugin that can be used to:
Install the plugin with NPM:
npm install --save-dev rollup-plugin-license
Then add it to your rollup configuration:
1const path = require('path'); 2const license = require('rollup-plugin-license'); 3 4module.exports = { 5 plugins: [ 6 license({ 7 sourcemap: true, 8 cwd: process.cwd(), // The default 9 10 banner: { 11 commentStyle: 'regular', // The default 12 13 content: { 14 file: path.join(__dirname, 'LICENSE'), 15 encoding: 'utf-8', // Default is utf-8 16 }, 17 18 // Optional, may be an object or a function returning an object. 19 data() { 20 return { 21 foo: 'foo', 22 }; 23 }, 24 }, 25 26 thirdParty: { 27 includePrivate: true, // Default is false. 28 includeSelf: true, // Default is false. 29 multipleVersions: true, // Default is false. 30 output: { 31 file: path.join(__dirname, 'dist', 'dependencies.txt'), 32 encoding: 'utf-8', // Default is utf-8. 33 }, 34 }, 35 }), 36 ], 37}
The banner file can be a text file and it will be converted to a block comment automatically if needed.
Note that the content will be translated to a lodash template with the following data model:
pkg
: The content of the project package.json
.dependencies
: An array of all the dependencies included in the bundle.moment
: The moment
object._
: The lodash object.data
A custom data object, defined in banner options.Here is a valid banner:
1Bundle of <%= pkg.name %> 2Generated: <%= moment().format('YYYY-MM-DD') %> 3Version: <%= pkg.version %> 4Dependencies: 5<% _.forEach(dependencies, function (dependency) { %> 6 <%= dependency.name %> -- <%= dependency.version %> 7<% }) %>
Since version 0.10.0, it is possible to customize banner style using the commentStyle
option:
1license({ 2 banner: { 3 commentStyle: 'regular', // The default 4 content: { 5 file: path.join(__dirname, 'LICENSE'), 6 }, 7 }, 8})
Following options are available:
regular
: "classic" comment block is used (this is the default), for example:1/** 2 * This is the `regular` style. 3 */
ignored
: a comment block with prefix ignored by minifiers, for example:1/*! 2 * This is the `ignored` style. 3 */
slash
: banner is prepended using "slash" comments, for example:1// 2// This is the `slash` style. 3//
none
: nothing done, be careful to prepenbd a banner already "commented".Since version 0.3.0, banner
can be a simple string that will be used directly:
1const license = require('rollup-plugin-license'); 2 3module.exports = { 4 plugins: [ 5 license({ 6 banner: `Copyright <%= moment().format('YYYY') %>`, 7 }), 8 ], 9}
If you want to add some options to banner (such as the comment style to use), and still define it as a string
(insead of pointing to a file), you can also define the banner like this (since version 0.11.0
):
1const license = require('rollup-plugin-license'); 2 3module.exports = { 4 plugins: [ 5 license({ 6 banner: { 7 content: `Copyright <%= moment().format('YYYY') %>`, 8 commentStyle: 'ignored', 9 }, 10 }), 11 ], 12}
Until version 0.10.0, banner file was defined as:
1const path = require('path'); 2const license = require('rollup-plugin-license'); 3 4module.exports = { 5 plugins: [ 6 license({ 7 banner: { 8 file: path.join(__dirname, 'LICENSE'), 9 encoding: 'utf-8', 10 }, 11 }), 12 ], 13};
This format has been deprecated with version 0.11.0 and removed with version 1.0.O, and the banner file should be defined inside banner.content
entry:
1const path = require('path'); 2const license = require('rollup-plugin-license'); 3 4module.exports = { 5 plugins: [ 6 license({ 7 banner: { 8 content: { 9 file: path.join(__dirname, 'LICENSE'), 10 encoding: 'utf-8', 11 }, 12 }, 13 }), 14 ], 15};
A file containing a summary of all dependencies can be generated automatically using the following options:
1license({ 2 thirdParty: { 3 output: path.join(__dirname, 'dist', 'dependencies.txt'), 4 includePrivate: true, // Default is false. 5 }, 6})
Starting with version 0.12.0
, you can have more control by defining output
as an object, for example:
1license({ 2 thirdParty: { 3 includePrivate: false, 4 output: { 5 file: path.join(__dirname, 'dist', 'dependencies.txt'), // Path of the license report 6 encoding: 'utf-8', // default is UTF-8 7 8 // Template function that can be defined to customize report output 9 template(dependencies) { 10 return dependencies.map((dependency) => `${dependency.name}:${dependency.version} -- ${dependency.license}`).join('\n'); 11 }, 12 }, 13 }, 14})
Note that the template option can also be a lodash template:
1license({ 2 thirdParty: { 3 includePrivate: false, 4 output: { 5 file: path.join(__dirname, 'dist', 'dependencies.txt'), 6 7 // Lodash template that can be defined to customize report output 8 template: ` 9 <% _.forEach(dependencies, function (dependency) { %> 10 <%= dependency.name %>:<%= dependency.version%> -- <%= dependency.license %> 11 <% }) %> 12 `, 13 }, 14 }, 15})
For example, it can be relatively easy to produce a JSON output instead of a text file:
1license({ 2 thirdParty: { 3 includePrivate: false, 4 output: { 5 file: path.join(__dirname, 'dist', 'dependencies.json'), 6 template(dependencies) { 7 return JSON.stringify(dependencies); 8 } 9 }, 10 }, 11})
By default, the "self" package is ignored (by "self", we mean the package being built), but startint with version 3.4.0, you can force inclusion using the includeSelf
option:
1license({ 2 thirdParty: { 3 includeSelf: true, 4 output: { 5 file: path.join(__dirname, 'dist', 'dependencies.json'), 6 template(dependencies) { 7 return JSON.stringify(dependencies); 8 } 9 }, 10 }, 11})
Starting with version 0.13, it is possible to ensure that dependencies does not violate any license restriction. For example, suppose you want to limit dependencies with MIT or Apache-2.0 licenses, simply define the restriction such as:
1license({ 2 thirdParty: { 3 allow: '(MIT OR Apache-2.0)', 4 }, 5})
Note that the allow
value here should be a valid SPDX pattern (more information here).
The allow
option here will print a warning to the console for all license violation. Note that, if you want more control, it can also be defined as function:
1license({ 2 thirdParty: { 3 allow(dependency) { 4 return dependency.license === 'MIT'; 5 }, 6 }, 7})
The function defined here allow only MIT licenses, and will print a warning for anything else.
Finally, if emitting a warning is not enought for you, you can also choose to fail the build:
1license({ 2 thirdParty: { 3 allow: { 4 test: 'MIT', // Or a function that should returns `true` or `false` 5 failOnUnlicensed: true, // Fail if a dependency does not specify any licenses, default is `false` 6 failOnViolation: true, // Fail if a dependency specify a license that does not match given requirement, default is `false` 7 }, 8 }, 9})
Starting with version 3.1.0
, you can also use the multipleVersions
option to track dependencies in different version as a different dependency.
It can be particularly useful in case a dependency changed its license between two versions.
Note that this option is false
by default (mainly to keep backward compatibility).
1license({ 2 thirdParty: { 3 includePrivate: false, 4 multipleVersions: true, 5 output: { 6 file: path.join(__dirname, 'dist', 'dependencies.txt'), // Path of the license report 7 encoding: 'utf-8', // default is UTF-8 8 template(dependencies) { 9 return dependencies.map((dependency) => `${dependency.name}:${dependency.version} -- ${dependency.license}`).join('\n'); 10 }, 11 }, 12 }, 13})
includePrivate
flag (see comment).multipleVersions
option is correctly validated (#1682)thirdParty.multipleVersions
option (#1528)LICENCE
or LICENSE
files (PR), thanks @codepunkt!output
configuration (see #379).thirdParty.encoding
option.NULL
character (see #1).sourceMap
option (use sourcemap
option in lowercase) to keep it consistent with rollup.cwd
option to specify custom working directory (optional option).commenting
dependency.sourcemap
option).sourcemp
is used instead of the "global" one in rollup options.moment
).magic-string
).MIT License (MIT)
If you find a bug or think about enhancement, feel free to contribute and submit an issue or a pull request.
No vulnerabilities found.
Reason
30 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
packaging workflow detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-11
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More@jihchi/vite-plugin-rescript
[![Workflows - CI][workflows-ci-shield]][workflows-ci-url] [![npm package][npm-package-shield]][npm-package-url] [![bundlephobia size][bundlephobia-size-shield]][bundlephobia-size-url] ![npm download per month][npm-download-shield] [![npm license][npm-lic
@vertigis/rollup-plugin-license
Rollup plugin to add license banner to the final bundle and output third party licenses
rollup-license-plugin
Extracts OSS license information of the npm packages in your rollup or vite output
cumqueratione
Rollup plugin to append content before js bundle