@hyperfrontend/builder/package/licenseslicenses
Opt-in third-party license collection.
collectThirdPartyLicenses(workspaceRoot, externals) scans the workspace node_modules for each external dependency, parses its package.json, locates a LICENSE file with case-insensitive matching, and infers the SPDX identifier — falling back to the license field when content-based detection is inconclusive. generateThirdPartyLicensesContent renders the collection as a markdown table; writeThirdPartyLicensesFile emits the file at the dist root. The license-URL builder lives in license-url.ts and supports GitHub, GitLab, and Bitbucket; other platforms resolve to null.
API Reference
ƒ Functions
collectThirdPartyLicenses(workspaceRoot: string, externals: string[]): ThirdPartyLicenseEntry[]
The dependency list is supplied by the caller (typically the resolved external list from the bundle phase, with workspace-internal entries already removed). For each dependency, the function locates the installed package under
<workspaceRoot>/node_modules, parses its package.json, scans for a LICENSE file, and attempts to derive a canonical license URL from the upstream repository field. Missing dependencies are logged at warn level and dropped from the result.Parameters
Returns
ThirdPartyLicenseEntry[]Example
Collecting licenses for a built library's bundle phase externals
const entries = collectThirdPartyLicenses('/abs/repo', ['rollup', 'typescript'])THIRD_PARTY_LICENSES.md from a collected list of license entries. The output is a top-level heading followed by a two-column table mapping each dependency to a markdown link pointing at the upstream license file (or the raw license type when no URL is available). The body always ends with a trailing newline.
Parameters
| Name | Type | Description |
|---|---|---|
§entries | ThirdPartyLicenseEntry[] | License entries produced by collectThirdPartyLicenses. |
Returns
stringExample
Generating the markdown body from a license collection
const md = generateThirdPartyLicensesContent(entries)<outputPath>/THIRD_PARTY_LICENSES.md. Parent directories are created if necessary by the underlying project-scope writer.Parameters
Example
Writing the file at the dist root
writeThirdPartyLicensesFile(ctx.outputPath, content)