LPM CLI

lpm pack

Build libraries with project-local tsdown, declaration files, workspace selection, and JSON results.

Build library JavaScript and declaration files with tsdown. LPM CLI finds your project's tsdown executable and can build selected workspace members.

lpm pack [OPTIONS] [ARGS]...

Quickstart

lpm install -D tsdown@0.23.0
lpm pack --entry src/index.ts --out-dir dist --format esm --dts

The examples use tsdown 0.23.0. That version requires Node ^22.18.0 || ^24.11.0 || >=26.0.0.

The command supports single builds, workspace builds, and explicit watch mode. To upload the built package, use lpm publish.

Project configuration

Keep tsdown in devDependencies. lpm install records the package version and lockfile resolution.

Select Node in lpm.json:

lpm.json
{
  "runtime": {
    "node": "22"
  }
}
lpm use node@22
lpm pack --entry src/index.ts --out-dir dist

The pack command uses an installed managed runtime selected by lpm.json, .nvmrc, or .node-version. It does not download a missing runtime. lpm use installs the runtime.

A workspace member inherits the root's Node selection unless it selects its own Node version. A Bun-only member selection retains the inherited Node selection.

If the selected Node version is unavailable, lookup falls back to the inherited PATH. An unavailable member selection does not use the root's managed Node selection.

tsdown configuration

tsdown.config.mjs
export default {
  entry: ['src/index.ts'],
  format: ['esm', 'cjs'],
  outDir: 'dist',
  dts: true,
};
lpm pack
lpm pack --config tsdown.config.mjs --minify

Tsdown loads its own configuration. CLI arguments override matching values. There is no lpm.json section for tsdown build options.

Tsdown 0.23.0 searches for tsdown.config.ts, .mts, .cts, .js, .mjs, .cjs, and .json, then package.json#tsdown. Its configuration search can reach ancestor directories.

An explicit configuration file sets tsdown's default working directory to that file's directory. To disable automatic configuration discovery for one run:

lpm pack --entry src/index.ts --out-dir dist -- --no-config

If src/index.ts exists, tsdown 0.23.0 uses it when no entries are configured. The default output directory is dist.

Recipes

Build declarations

lpm pack --entry src/index.ts --format esm --dts
lpm pack --config tsdown.config.mjs --tsconfig tsconfig.build.json

Tsdown can enable declarations from package metadata or TypeScript configuration. --dts enables them explicitly. To disable declarations for one run:

lpm pack --entry src/index.ts -- --no-dts

Target Node or browsers

lpm pack --entry src/index.ts --platform node --target es2022
lpm pack --entry src/index.ts --platform browser --minify --sourcemap

Watch one project

lpm pack -- --watch
lpm pack --filter shared -- --watch src

Workspace watch requires exactly one selected member. Explicit watch mode rejects --json.

Tsdown's watch option accepts a path. --watch=false watches a path named false. To disable watch mode, use --no-watch:

lpm pack -- --no-watch

A single human-output run honors watch mode from tsdown configuration. JSON and workspace runs disable configuration-only watch automatically. Add an explicit --watch option for a workspace watcher.

Build in CI

lpm pack --all --json
lpm pack --filter shared --fail-if-no-match --json

The command requires no interactive input. Install dependencies and a compatible Node runtime before the build.

Forward other tsdown options

lpm pack --entry src/index.ts -- --clean --exports
lpm pack -- --help

Arguments after -- go to tsdown unchanged, except that finite JSON and workspace runs add --no-watch. --entry becomes a positional tsdown input.

Local executable selection

LPM CLI searches node_modules/.bin from the current directory to the project or workspace root. A workspace-root tsdown installation is available to its members.

The command requires a local tsdown executable. It does not install tsdown or use a global tsdown from PATH.

Node lookup uses local .bin directories, then selected managed runtimes, then the inherited PATH. Automatic local lookup stops at the project or workspace root.

On Windows, a local .cmd shim takes precedence over its adjacent extensionless shell script.

Workspaces

lpm pack --all
lpm pack --filter shared --filter ui
lpm pack --filter './packages/*'
lpm pack --filter-prod '...shared'
lpm pack --affected --base origin/main

Each selected member runs from its own directory. Selected dependencies run before their dependents. Independent members can run concurrently, up to the host CPU count.

--all conflicts with --filter, --filter-prod, and --affected. Filters and --affected combine their selections.

An empty selection succeeds without a build. If a selected member must exist, add --fail-if-no-match. Watch mode always rejects an empty selection.

See workspace filters for dependency closures, exclusions, path patterns, and Git references.

JSON and exit codes

lpm pack --entry src/index.ts --out-dir dist --json
lpm pack --all --json

Both modes emit one JSON object with member results, exit codes, and durations. Failed members include captured diagnostics. Successful members omit captured output.

A launch failure has exit_code: null and an error message. Earlier preparation errors can use the standard error object.

See the lpm lint JSON example for the envelope shape. LPM CLI retains at most 10 MiB per output stream, with a truncation marker for longer diagnostics.

Single-project runs preserve tsdown's exit code. Workspace runs exit 1 if any member fails. On Unix, interruption stops active tool descendants and exits 130 for SIGINT or 143 for SIGTERM.

Recovery

If tsdown is missing, install it in the project or workspace root:

lpm install -D tsdown@0.23.0

If Node cannot start, install a compatible runtime with lpm use. If configuration parsing fails, correct the reported configuration file before retrying.

If tsdown finds no entry, pass --entry or set entry in its configuration. If declarations fail, inspect the TypeScript diagnostics and the selected --tsconfig file.

Flags

FlagEffect
--entry <ENTRY>Positional tsdown input file.
--out-dir <OUT_DIR>Output directory.
--config <CONFIG>Explicit tsdown configuration file.
--tsconfig <TSCONFIG>TypeScript configuration file.
--target <TARGET>Target runtime or JavaScript version.
--format <FORMAT>Output format: esm, cjs, or iife.
--platform <PLATFORM>Target platform: node, browser, or neutral.
--dtsGenerate declaration files.
--minifyMinify the output.
--sourcemapGenerate a source map.
--allRun in every workspace member. Conflicts with filters and --affected.
--filter <FILTER>Select members with a repeatable workspace filter.
--filter-prod <FILTER_PROD>Select members with production-only dependency closures.
--affectedSelect changed members and their affected dependents.
--base <BASE>Git base for --affected. Default: main.
--changed-files-ignore-pattern <PATTERN>Ignore matching changed paths. Repeatable.
--test-pattern <PATTERN>Treat matching changes as tests when calculating dependent selection. Repeatable.
--fail-if-no-matchFail when the workspace selection is empty.
[ARGS]...Arguments forwarded to tsdown. Use -- to separate them from LPM CLI flags.

See global flags for --json and other shared options.

See also