# build Builds a library into a publishable package with [`@hyperfrontend/builder`](https://www.hyperfrontend.dev/docs/libraries/builder.md), deciding what holds for every workspace: the packages the workspace's own projects carry are first-party (inlined where a format asks, left out of the published dependencies), the repository fields come from the root manifest, third-party licences are collected, and the project's README and changelog travel with the package. ```json { "build": { "executor": "@hyperfrontend/workspace:build", "options": { "esm": { "bundleWorkspaceDeps": false }, "cjs": { "bundleWorkspaceDeps": false }, "iife": { "entry": ".", "globalName": "AcmeMyUtils" }, "rootAssets": ["LICENSE.md"] } } } ``` | Option | What it does | | ------ | ------------ | | `--outputPath` | Where the package is written, relative to the root; defaults to `dist/` | | `--tsConfig` | The TypeScript configuration, relative to the root; defaults to `tsconfig.lib.json` in the project | | `--rootAssets` | Files at the root copied into the package when they exist; `FUNDING.md` only into a package that declares funding | | `--assets` | Further files to copy, each a source directory with file names or a glob and a destination | | `--external` | Packages kept external in every format | | `--esm, --cjs` | The two module formats: entries, source maps, externals, whether workspace or all dependencies are inlined | | `--iife, --umd` | The two browser bundles: the entry, the global name, minification, externals and their globals | | `--bin` | Executables to write beside the library from `src/bin/.ts`, in either module format | | `--dedupeSharedInternals` | Hoists first-party modules shared by several entries into one chunk; defaults to true | | `--clean` | Empties the output directory first, when it is empty or holds a previous build; defaults to true | | `--verbose` | Prints the build's diagnostics | Each format is omitted to skip it. The options of a format are the builder's own, and are documented with it. ## API Reference ### Functions #### rootAssetSpecs ```typescript function rootAssetSpecs(root: string, names: unknown): AssetSpec[] ``` The assets copied from the workspace root. **Parameters** | Name | Type | Description | | --- | --- | --- | | `root` | `string` | The workspace root, absolute | | `names` | `unknown` | The files, relative to the root | **Returns** `AssetSpec[]`: One asset spec per file that exists, the funding file conditional on the package declaring `funding` **Example: A missing file is skipped, the funding file is conditional** ```typescript rootAssetSpecs('/repo', ['LICENSE', 'FUNDING.md', 'NOTICE']) // => [ // { from: '/repo', files: ['LICENSE'] }, // { from: '/repo', files: ['FUNDING.md'], condition: (manifest) => Boolean(manifest.funding) }, // ] when /repo has no NOTICE ``` ### Interfaces #### BuildExecutorOptions Schema-validated executor options. Mirrors `BuildConfig` from `@hyperfrontend/builder/models` minus what the executor decides for every workspace (`isWorkspacePackage`, `filterWorkspaceDepsFromOutput`, `inheritFieldsFrom`, `thirdPartyLicenses`, `memoryMonitor`). **Properties** | Name | Type | Description | | --- | --- | --- | | `outputPath?` | `string` | Output directory, relative to the workspace root. Defaults to `dist/`. | | `tsConfig?` | `string` | Path to tsconfig, relative to the workspace root. Defaults to `/tsconfig.lib.json`. | | `rootAssets?` | `string[]` | Files at the workspace root copied into the package when they exist, such as a licence. `FUNDING.md` is copied only into a package that declares `funding`. | | `assets?` | `AssetSpec[]` | Additional asset specs to copy in addition to the project's README and changelog and the root assets. | | `external?` | `string[]` | Global externals applied to every format. | | `esm?` | `EsmConfig \| EsmConfig[]` | ESM output configuration. Omit to skip. | | `cjs?` | `CjsConfig \| CjsConfig[]` | CommonJS output configuration. Omit to skip. | | `iife?` | `IifeConfig \| IifeConfig[]` | IIFE bundle configuration. Omit to skip. | | `umd?` | `UmdConfig \| UmdConfig[]` | UMD bundle configuration. Omit to skip. | | `unpkg?` | `string` | Override path for the unpkg field. Defaults to the first UMD bundle path. | | `jsdelivr?` | `string` | Override path for the jsdelivr field. Defaults to the first UMD bundle path. | | `bin?` | `BinConfig[]` | Bin declarations to synthesize alongside the library. | | `dedupeSharedInternals?` | `boolean` | Hoist first-party modules shared across entry bundles into `_shared/` chunks. Defaults to enabled. | | `verbose?` | `boolean` | Enable verbose / debug logging. | | `clean?` | `boolean` | Empty the output directory before emitting. Defaults to enabled; only an empty directory or a previous build of this package is removed. | ### Variables #### buildExecutor Builds a library into a publishable package. ```typescript const buildExecutor: Executor ``` **Value** `...` #### FUNDING_ASSET The root asset that travels only with a package that declares `funding`. ```typescript const FUNDING_ASSET: "FUNDING.md" ``` **Value** `'FUNDING.md'` --- Canonical page: https://www.hyperfrontend.dev/docs/libraries/workspace/executors/build/ This file: https://www.hyperfrontend.dev/docs/libraries/workspace/executors/build.md Documentation index: https://www.hyperfrontend.dev/llms.txt