@hyperfrontend/builder/packagepackage
Package subdomain facade: package.json synthesis + write, generic asset copy, and opt-in third-party license collection.
runPackagePhase(context, config, formatOutputs) composes synthesizePackageJson with the resolved build context, writes the dist package.json, materializes the configured AssetSpec list via copyAssets, and, when config.thirdPartyLicenses is enabled, derives the external dependency list from the synthesized package, runs collectThirdPartyLicenses, and emits THIRD_PARTY_LICENSES.md. Each step is also exposed as a standalone primitive under the ./package/json, ./package/assets, and ./package/licenses subpaths so wrappers can compose them directly.
API Reference
ƒ Functions
package.json#files as the last build step, after every emit phase (bundle → package → bin → license/asset) and the orphan prune have run. The allowlist is reflected from the materialized output tree rather than predicted from config, so the field names exactly what ships. Call this last: earlier phases (notably the bin phase) emit files after the package phase writes the manifest, and reflecting before then would miss those survivors. An explicit
config.files short-circuits reflection and is honored verbatim. An empty allowlist (only possible via an explicit
config.files: []) leaves the manifest untouched.Parameters
| Name | Type | Description |
|---|---|---|
§ctx | BuildContext | Resolved build context (provides outputPath). |
§config | BuildConfig | Top-level builder configuration; reads the files override. |
Example
Finalizing the allowlist after the bin phase
const binOutputs = await runBinPhase(ctx, config.bin ?? [])
finalizeFilesAllowlist(ctx, config)runPackagePhase(ctx: BuildContext, config: BuildConfig, formatOutputs: FormatOutputs): Promise<void>
package.json, materializes any configured asset specs, and (when config.thirdPartyLicenses is enabled, defaulting to true for builds with at least one bundled dep) emits THIRD_PARTY_LICENSES.md. The phase consumes:
- the source
package.json(read fresh fromctx.projectRoot) - the resolved BuildContext (output path, workspace predicate, assets, discovery)
- the FormatOutputs aggregated by the bundle phase
dependencies map only when both config.filterWorkspaceDepsFromOutput and ctx.isWorkspacePackage are present. Inheritance and CDN overrides are forwarded verbatim to synthesizePackageJson.Parameters
| Name | Type | Description |
|---|---|---|
§ctx | BuildContext | Resolved build context. |
§config | BuildConfig | Top-level builder configuration. Reads inheritFieldsFrom, filterWorkspaceDepsFromOutput, unpkg, jsdelivr, bin, and thirdPartyLicenses. The files allowlist is owned by finalizeFilesAllowlist, not this phase. |
§formatOutputs | FormatOutputs | Outputs collected during the bundle phase. |
Example
Driving the package phase from a custom orchestrator
await runPackagePhase(context, config, formatOutputs)