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.

Principle:Promptfoo Promptfoo Build And Packaging

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

Overview

Principle governing the TypeScript compilation, bundling, and packaging pipeline that produces ESM/CJS library builds, a CLI binary, and a server bundle from a single source tree.

Description

Build and Packaging defines how the promptfoo monorepo source code is transformed into distributable artifacts. The pipeline uses tsdown as the bundler, producing four output targets from a single TypeScript source: (1) Server ESM build, (2) CLI binary ESM with shebang header, (3) Library ESM for import consumers, and (4) Library CJS for require consumers. Compile-time constants (version, analytics keys, min Node version) are injected during bundling. Dependencies are externalized for Node.js native resolution. Package manifests and lockfiles ensure reproducible dependency installation.

Usage

Apply this principle when modifying build configuration, adding new entry points, or changing the module structure. Understand the four output targets to ensure changes work in all contexts.

Theoretical Basis

The build system follows the Multi-Target Compilation Pattern:

  • A single source tree produces multiple output formats (ESM, CJS)
  • Compile-time injection (define option) replaces placeholder constants with actual values at build time, avoiding runtime file reads
  • Dependency externalization delegates resolution to Node.js, reducing bundle size and avoiding CJS/ESM interop issues
  • Workspace configuration (npm workspaces) manages the monorepo structure with independent sub-packages for the web UI and documentation site

Related Pages

Page Connections

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