{"id":25366,"library":"esbuild-plugin-license","title":"esbuild-plugin-license","description":"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.","status":"active","version":"1.2.3","language":"javascript","source_language":"en","source_url":"https://github.com/upupming/esbuild-plugin-license#readme","tags":["javascript","license","esbuild","typescript"],"install":[{"cmd":"npm install esbuild-plugin-license","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-license","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-license","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required to use the plugin","package":"esbuild","optional":false}],"imports":[{"note":"Default export; named import does not work.","wrong":"import { esbuildPluginLicense } from 'esbuild-plugin-license'","symbol":"esbuildPluginLicense","correct":"import esbuildPluginLicense from 'esbuild-plugin-license'"},{"note":"TypeScript type import only; not a runtime value.","wrong":"import { Options } from 'esbuild-plugin-license'","symbol":"Options","correct":"import type { Options } from 'esbuild-plugin-license'"},{"note":"TypeScript type for the template callback parameter.","wrong":"","symbol":"Dependency","correct":"import type { Dependency } from 'esbuild-plugin-license'"}],"quickstart":{"code":"import * as esbuild from 'esbuild';\nimport esbuildPluginLicense from 'esbuild-plugin-license';\n\nawait esbuild.build({\n  entryPoints: ['src/index.ts'],\n  outdir: 'dist',\n  bundle: true,\n  platform: 'node',\n  plugins: [\n    esbuildPluginLicense({\n      banner: '/*! <%= pkg.name %> v<%= pkg.version %> */',\n      thirdParty: {\n        includePrivate: false,\n        output: {\n          file: 'dependencies.txt',\n          template(dependencies) {\n            return dependencies\n              .map(d => `${d.packageJson.name}:${d.packageJson.version} -- ${d.packageJson.license}`)\n              .join('\\n');\n          },\n        },\n      },\n    }),\n  ],\n});","lang":"typescript","description":"Shows full usage: configure esbuild with the plugin, custom banner, and third-party license output as a text file."},"warnings":[{"fix":"Update template function signature to use the second parameter 'self' for the entry package.","message":"In 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.","severity":"breaking","affected_versions":">=1.1.0"},{"fix":"No action needed; output may change if duplicates existed.","message":"In v1.1.0, when multiple versions of the same package exist, the highest version is now used deterministically instead of undefined behavior.","severity":"breaking","affected_versions":">=1.1.0"},{"fix":"Use default import: `import esbuildPluginLicense from 'esbuild-plugin-license'`.","message":"Default export is used; named import syntax `import { esbuildPluginLicense }` will fail.","severity":"gotcha","affected_versions":"*"},{"fix":"Set `platform: 'node'` and ensure the bundle does not use ESM-only features that break Node CJS interop.","message":"The plugin does not work with esbuild's `format: 'esm'` if you rely on `__dirname` or `require` in Node.js; bundle must be compatible.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Update template function to accept two parameters: `function(dependencies, self)` and use `self.packageJson` for the entry package.","cause":"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'.","error":"Error: esbuild-plugin-license: Cannot read properties of undefined (reading 'packageJson')"},{"fix":"Replace `import { esbuildPluginLicense }` with `import esbuildPluginLicense`.","cause":"Using named import instead of default import.","error":"Error: The plugin 'esbuild-plugin-license' must be imported as default."},{"fix":"Provide a function: `template(dependencies) { ... return string; }`.","cause":"The 'template' option receives a function returning a string, not a template string or object.","error":"Error: esbuild-plugin-license: Expected a function for 'template' option, got object."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}