@hyperfrontend/builder/package

package

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

§function

finalizeFilesAllowlist(ctx: BuildContext, config: BuildConfig): void

Finalizes 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

NameTypeDescription
§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)
§function

runPackagePhase(ctx: BuildContext, config: BuildConfig, formatOutputs: FormatOutputs): Promise<void>

Runs the complete package phase: synthesizes and writes the dist 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 from ctx.projectRoot)
  • the resolved BuildContext (output path, workspace predicate, assets, discovery)
  • the FormatOutputs aggregated by the bundle phase
Workspace-internal entries are stripped from the published dependencies map only when both config.filterWorkspaceDepsFromOutput and ctx.isWorkspacePackage are present. Inheritance and CDN overrides are forwarded verbatim to synthesizePackageJson.

Parameters

NameTypeDescription
§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)