Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Promptfoo Promptfoo Tsdown Build Config

From Leeroopedia
Knowledge Sources
Domains Build_System, Configuration
Last Updated 2026-02-14 07:45 GMT

Overview

Build configuration for tsdown (TypeScript bundler) that defines four output targets: server ESM, CLI binary ESM, library ESM, and library CJS.

Description

The Tsdown_Build_Config (tsdown.config.ts) defines four build configurations using tsdown's defineConfig: (1) Server ESM build for src/server/index.ts, (2) CLI binary ESM build for entrypoint.ts and main.ts with a #!/usr/bin/env node banner, (3) Library ESM build for src/index.ts with tree shaking, and (4) Library CJS build for backward compatibility. All builds inject compile-time constants (VERSION, POSTHOG_KEY, MIN_NODE_VERSION, BUILD_FORMAT) and externalize bare module imports for Node.js resolution.

Usage

This file is read by tsdown during npm run build. It defines how the TypeScript source is compiled and bundled for distribution.

Code Reference

Source Location

Signature

import { defineConfig } from 'tsdown';

export default defineConfig([
  { /* Server ESM */ },
  { /* CLI binary ESM */ },
  { /* Library ESM */ },
  { /* Library CJS */ },
]);

Import

# Consumed by tsdown CLI
npx tsdown  # reads tsdown.config.ts automatically

I/O Contract

Inputs

Name Type Required Description
package.json File Yes Read for version constants
PROMPTFOO_POSTHOG_KEY env var No PostHog key for production builds

Outputs

Name Type Description
dist/src/server/index.js File Server ESM bundle
dist/src/entrypoint.js File CLI binary with shebang
dist/src/main.js File CLI main module
dist/src/index.js File Library ESM bundle
dist/src/index.cjs File Library CJS bundle

Usage Examples

# Build all targets
npm run build

# Watch mode for development
npm run build:watch

# Clean build
npm run build:clean && npm run build

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment