API Reference
Exported functions, types, and utilities
withPresets
Composes configuration fragments in declaration order, then applies the surrounding user configuration last.
import { withPresets } from "@octopus-energy/tsdown";withPresetsProp
Type
mergeConfig
Deeply merges tsdown configuration. Later scalar values win, while arrays, entries, hooks, and custom exports compose in declaration order.
import { mergeConfig } from "@octopus-energy/tsdown";mergeConfigProp
Type
library
Provides defaults for ESM TypeScript libraries. The preset does not set an entry, so tsdown supplies its conventional entry when none is configured.
import { library } from "@octopus-energy/tsdown";libraryProp
Type
Defaults
| Option | Value |
|---|---|
clean | true |
deps.resolveDepSubpath | true |
dts | true |
entry | Not set |
exports | {} |
format | "esm" |
ignoreWatch | [/coverage/] |
minify | true |
nodeProtocol | "strip" |
unbundle | true |
cli
Declares package executables and derives their named build entries, development and published bin metadata, and normal-export exclusions.
import { cli } from "@octopus-energy/tsdown";cliProp
Type
CliPresetOptionsProp
Type
Defaults
| Option | Value |
|---|---|
entry | Named entries for the first executable of each unique source |
exports.bin | bin |
exports.devExports | true |
exports.exclude | Named entries generated from bin |
By default, every executable is excluded from normal package exports. Set exclude to an array of bin executable names to exclude only those binaries; the names are type-checked against the supplied bin keys. exclude: true has the same effect as omitting the option, while exclude: false or an empty array omits exports.exclude.
The first executable name for each unique source becomes its named entry and emitted filename. Additional executable names for that source are aliases to the same file. For example, oe.example emits dist/oe.example.mjs.
Development exports cause generated package exports and executable entries to point to source files. Published metadata continues to point to build output. Set exports.devExports: false in the surrounding configuration when the package's source cannot execute directly in its supported Node.js versions.
docs
Copies package-local documentation into the package build and generates a deterministic page catalog.
import { docs } from "@octopus-energy/tsdown";docsProp
Type
DocsPresetOptionsProp
Type
Defaults
| Option | Value |
|---|---|
source | "docs" |
output | "docs" |
exclude | [] |
transform | undefined |
Markdown and MDX documents require a non-empty string title and may provide a string description, resolved from frontmatter after transform metadata overrides. Invalid metadata fails the build with the document path and invalid fields. Other included files are copied as assets. The generated index.json catalogs transformed document paths and metadata relative to the docs output directory.
Source paths must remain inside the package, and emitted paths must remain inside the configured docs output. Source and output directories cannot overlap. Path checks do not resolve symlinks. Emitted documents and assets cannot collide, including when paths differ only by letter case, and the root index.json path is reserved for the generated catalog.
react
Adds runtime-neutral React settings and experimental native Oxc React Compiler support enabled by default.
import { react } from "@octopus-energy/tsdown";reactProp
Type
ReactPresetOptionsProp
Type
Defaults
| Option | Value |
|---|---|
platform | "neutral" |
compiler | true |
The compiler option accepts true, false, "ci-only", "local-only", or native React Compiler options with an enabled property. It requires @vitejs/plugin-react and oxc-transform-react.
panda
Adds PandaCSS buildinfo generation and its package export.
import { panda } from "@octopus-energy/tsdown";pandaProp
Type
Defaults
| Option | Value |
|---|---|
hooks["build:before"] | generatePandaBuildinfo |
exports.customExports | addPandaBuildinfoExport |
Requires @pandacss/dev and a panda.config.ts file in the package directory.
validate
Adds publint and unused-export validation.
import { validate } from "@octopus-energy/tsdown";validateProp
Type
ValidatePresetOptionsProp
Type
Defaults
| Option | Value |
|---|---|
publint.enabled | "ci-only" |
publint.level | "error" |
unused.enabled | "ci-only" |
unused.level | "error" |
Requires publint and unplugin-unused for the corresponding checks.
reactCompilerPlugin
Creates Vite's React plugins with the experimental native Oxc React Compiler enabled. Generated declaration files and dependencies are excluded from compilation.
import { reactCompilerPlugin } from "@octopus-energy/tsdown";reactCompilerPluginProp
Type
ReactCompilerOptionsProp
Type
addPandaBuildinfoExport
Adds ./panda.buildinfo.json to generated package exports.
import { addPandaBuildinfoExport } from "@octopus-energy/tsdown";addPandaBuildinfoExportProp
Type
generatePandaBuildinfo
Runs panda ship before a build to generate Panda buildinfo.
import { generatePandaBuildinfo } from "@octopus-energy/tsdown";generatePandaBuildinfoProp
Type