Registry / devops / esbuild-plugin-license

esbuild-plugin-license

JSON →
library1.2.3jsnpmunverified

esbuild plugin to generate license files for bundled dependencies. Current stable version is 1.2.3. It is actively maintained with regular releases. Key differentiators: generates both a banner for the bundle and a separate third-party license file, uses a template system based on EJS and offers a custom template function. Compared to alternatives like rollup-plugin-license, it is designed specifically for esbuild.

npm install esbuild-plugin-license
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-LIC
E
esbuild-plugin-license
devopsjavascriptv1.2.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

esbuildPluginLicense
import esbuildPluginLicense from 'esbuild-plugin-license'
import { esbuildPluginLicense } from 'esbuild-plugin-license'
Default export; named import does not work.
Options
import type { Options } from 'esbuild-plugin-license'
import { Options } from 'esbuild-plugin-license'
TypeScript type import only; not a runtime value.
Dependency
import type { Dependency } from 'esbuild-plugin-license'
TypeScript type for the template callback parameter.

Shows full usage: configure esbuild with the plugin, custom banner, and third-party license output as a text file.

import * as esbuild from 'esbuild'; import esbuildPluginLicense from 'esbuild-plugin-license'; await esbuild.build({ entryPoints: ['src/index.ts'], outdir: 'dist', bundle: true, platform: 'node', plugins: [ esbuildPluginLicense({ banner: '/*! <%= pkg.name %> v<%= pkg.version %> */', thirdParty: { includePrivate: false, output: { file: 'dependencies.txt', template(dependencies) { return dependencies .map(d => `${d.packageJson.name}:${d.packageJson.version} -- ${d.packageJson.license}`) .join('\n'); }, }, }, }), ], });
Debug
Known issues
breakingIn v1.1.0, the entry package is no longer included as a dependency in the third-party output; instead it is provided separately as 'self' in the template function.
fix
Update template function signature to use the second parameter 'self' for the entry package.
affects: >=1.1.0
breakingIn v1.1.0, when multiple versions of the same package exist, the highest version is now used deterministically instead of undefined behavior.
fix
No action needed; output may change if duplicates existed.
affects: >=1.1.0
gotchaDefault export is used; named import syntax `import { esbuildPluginLicense }` will fail.
fix
Use default import: `import esbuildPluginLicense from 'esbuild-plugin-license'`.
affects: *
gotchaThe plugin does not work with esbuild's `format: 'esm'` if you rely on `__dirname` or `require` in Node.js; bundle must be compatible.
fix
Set `platform: 'node'` and ensure the bundle does not use ESM-only features that break Node CJS interop.
affects: *
Errors
Common errors & fixes
Error: esbuild-plugin-license: Cannot read properties of undefined (reading 'packageJson')
Template function signature changed in v1.1.0; the first parameter is still dependencies but the entry package is now in the second parameter 'self'.
fix
Update template function to accept two parameters: `function(dependencies, self)` and use `self.packageJson` for the entry package.
Error: The plugin 'esbuild-plugin-license' must be imported as default.
Using named import instead of default import.
fix
Replace `import { esbuildPluginLicense }` with `import esbuildPluginLicense`.
Error: esbuild-plugin-license: Expected a function for 'template' option, got object.
The 'template' option receives a function returning a string, not a template string or object.
fix
Provide a function: `template(dependencies) { ... return string; }`.
Upgrade
Version history
1.2.3latest on npm
Audit
Dependencies
esbuildrequiredpeer dependency required to use the plugin
Agent activity
4 hits · last 30 days
node
4
Resources
esbuild-plugin-license — npm install esbuild-plugin-license · libregistry