Skip to content

silverwind/rolldown-license-plugin

Repository files navigation

rolldown-license-plugin

Rolldown plugin to extract dependency licenses.

Usage

import {licensePlugin} from "rolldown-license-plugin";

export default {
  plugins: [
    licensePlugin({
      done(deps) {
        console.info(deps);
        // => [{name, version, license, licenseText}]
      },
    }),
  ],
};

API

licensePlugin(opts)

Returns the plugin.

opts.done

Type: (licenses: LicenseInfo[], context: PluginContext) => void | Promise<void>

Callback invoked during generateBundle with the collected license data. The context parameter provides access to rolldown's plugin context, including emitFile.

opts.match

Type: RegExp
Default: /^((UN)?LICEN(S|C)E|COPYING).*$/i

Regex to match license filenames in package directories.

opts.wrapText

Type: number

When set, word-wrap licenseText to this column width.

opts.allow

Type: (license: LicenseInfo) => boolean

Validate each dependency's license. Return false to reject it. By default, rejected dependencies are warned via console.warn. Use failOnViolation and failOnUnlicensed to throw build errors instead.

opts.failOnViolation

Type: boolean
Default: false

Throw a build error when a dependency has an incompatible license.

opts.failOnUnlicensed

Type: boolean
Default: false

Throw a build error when a dependency does not specify any license.

LicenseInfo

type LicenseInfo = {
  name: string;        // package name
  version: string;     // package version
  license: string;     // SPDX license identifier from package.json
  licenseText: string; // contents of LICENSE/COPYING file, or ""
};

wrap(text, width)

Function to word-wrap text to a certain column width. Returns the wrapped string.

License

© silverwind, distributed under BSD-2-Clause.

About

Rolldown plugin to extract dependency licenses

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors