Skip to Content
Octopus Energy Packages

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";
withPresets

Prop

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";
mergeConfig

Prop

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";
library

Prop

Type

Defaults

OptionValue
cleantrue
deps.resolveDepSubpathtrue
dtstrue
entryNot set
exports{}
format"esm"
ignoreWatch[/coverage/]
minifytrue
nodeProtocol"strip"
unbundletrue

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";
cli

Prop

Type

CliPresetOptions

Prop

Type

Defaults

OptionValue
entryNamed entries for the first executable of each unique source
exports.binbin
exports.devExportstrue
exports.excludeNamed 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";
docs

Prop

Type

DocsPresetOptions

Prop

Type

Defaults

OptionValue
source"docs"
output"docs"
exclude[]
transformundefined

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";
react

Prop

Type

ReactPresetOptions

Prop

Type

Defaults

OptionValue
platform"neutral"
compilertrue

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";
panda

Prop

Type

Defaults

OptionValue
hooks["build:before"]generatePandaBuildinfo
exports.customExportsaddPandaBuildinfoExport

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";
validate

Prop

Type

ValidatePresetOptions

Prop

Type

Defaults

OptionValue
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";
reactCompilerPlugin

Prop

Type

ReactCompilerOptions

Prop

Type


addPandaBuildinfoExport

Adds ./panda.buildinfo.json to generated package exports.

import { addPandaBuildinfoExport } from "@octopus-energy/tsdown";
addPandaBuildinfoExport

Prop

Type


generatePandaBuildinfo

Runs panda ship before a build to generate Panda buildinfo.

import { generatePandaBuildinfo } from "@octopus-energy/tsdown";
generatePandaBuildinfo

Prop

Type

On this page