Reliverse Docs

dler build

Build workspace packages using configurable bundler

Build all workspace packages using configurable bundler with support for multiple presets, bundlers, and optimization options.

Usage

dler build [options]

Description

The build command builds all workspace packages using a configurable bundler system. It automatically detects frontend apps and libraries, supports presets for common build scenarios, and provides extensive customization options for bundling, optimization, and deployment.

Quick Start

Basic build

dler build

Production build

dler build --production

Development build with watch

dler build --dev

Library build

dler build --library

Package Selection

OptionTypeDescription
--filter <packages>stringPackage(s) to include (supports wildcards and comma-separated values like '@reliverse/rempts,@reliverse/build'). Takes precedence over --ignore.
--ignore <packages>stringPackage(s) to ignore (supports wildcards like @reliverse/*).
--cwd <path>stringWorking directory (monorepo root).
--concurrency <number>numberNumber of packages to build concurrently (default: 5).
--stop-on-errorbooleanStop on first error instead of collecting all errors (default: false).

Build Configuration

Entry & Output

OptionShortTypeDescription
--entry <file>-estringEntry file (defaults to auto-detect), supports comma-separated multiple entries.
--outdir <dir>-ostringOutput directory.
--outfile <file>stringOutput filename (for single executable).

Bundler & Target

OptionTypeDescription
--bundler <bundler>stringBundler to use: bun (fast, bundles deps) or mkdist (preserves structure, default for libraries).
--target <target>stringBuild target: browser, bun, or node (default: bun).
--runtime <runtime>-r'bun' | 'node'

Compilation

OptionTypeDescription
--compilebooleanGenerate standalone executable (default: false).
--targets <targets>-tstring
--compressbooleanCompress multi-target builds into tar.gz files (default: false).

Optimization

Minification

OptionTypeDescription
--minifybooleanEnable all minification options (default: false).
--minify-whitespacebooleanMinify whitespace (default: false).
--minify-syntaxbooleanMinify syntax and inline constants (default: false).
--minify-identifiersbooleanMinify variable and function identifiers (default: false).

Code Splitting

OptionTypeDescription
--splittingbooleanEnable code splitting (default: true).
--external <packages>stringExternal packages to exclude from bundle (supports wildcards).
--packages <mode>stringHow to handle dependencies: bundle or external (default: bundle).

Output Format

OptionTypeDescription
--format <format>stringOutput format: esm, cjs, or iife (default: esm).
--sourcemap <option>stringSourcemap option: none, linked, inline, or external (default: none).

Development

Watch & Hot Reload

OptionTypeDescription
--watchbooleanWatch mode for hot rebuild (default: false).
--no-clear-screenbooleanDon't clear screen in watch mode (default: false).
--react-fast-refreshbooleanEnable React Fast Refresh (default: false).

Development Server

OptionTypeDescription
--dev-serverbooleanEnable development server (default: false).
--port <number>numberDevelopment server port (default: 3000).
--openbooleanOpen browser on dev server start (default: false).

Presets

Build Modes

OptionTypeDescription
--productionbooleanEnable production mode (minify=true, sourcemap=none, env=inline).
--devbooleanEnable development mode (watch=true, sourcemap=linked, env=disable).
--librarybooleanEnable library mode (packages=external, bundler=mkdist, generateTypes=true).

Framework Presets

OptionTypeDescription
--reactbooleanEnable React preset (jsx=automatic, target=browser).
--nodebooleanEnable Node preset (target=node, format=cjs).
--monorepobooleanEnable monorepo preset (concurrency=auto, validateTsconfig=true).

TypeScript & Types

OptionTypeDescription
--generate-typesbooleanGenerate TypeScript declaration files (default: false).
--type-checkbooleanRun type checking during build (default: false).
--validate-tsconfigbooleanValidate tsconfig.json for common issues (default: true).
--strict-tsconfigbooleanMake tsconfig validation errors fatal (default: false).
--dts-provider <provider>stringDTS generation provider: dts-bundle-generator, api-extractor, typescript, or mkdist (default: dts-bundle-generator).

Advanced Options

Environment & Constants

OptionTypeDescription
--env <mode>stringEnvironment variable handling: inline, disable, or prefix like PUBLIC_*.
--define <json>stringDefine global constants (JSON format, e.g., '{"VERSION":"1.0.0"}').

Naming & Paths

OptionTypeDescription
--public-path <path>stringPrefix for import paths in bundled code.
--root <path>stringProject root for resolving relative paths.
--naming <pattern>stringCustomize output file naming (JSON format).
--entry-naming <pattern>stringNaming pattern for entry files (e.g., '[dir]/[name].[ext]').
--chunk-naming <pattern>stringNaming pattern for chunk files (e.g., '[name]-[hash].[ext]').
--asset-naming <pattern>stringNaming pattern for asset files (e.g., '[name]-[hash].[ext]').

Bytecode & Performance

OptionTypeDescription
--bytecodebooleanGenerate bytecode for faster cold starts (requires format: cjs, target: bun).
--drop <calls>stringDrop function calls (e.g., 'console.log', 'debugger').

HTML & Assets

OptionTypeDescription
--htmlbooleanGenerate HTML file (default: false).
--public-assets <dir>stringPublic assets directory (default: 'public').
--assets <dir>stringAssets directory (default: 'assets').

Frameworks & Features

OptionTypeDescription
--appbooleanEnable app mode (default: false).
--server-componentsbooleanEnable server components support (default: false).
--css-modulesbooleanEnable CSS modules (default: false).
--css-chunkingbooleanEnable CSS chunking (default: false).
--svg-as-reactbooleanConvert SVG to React components (default: false).
--worker-supportbooleanEnable worker support (default: false).
--macrosbooleanEnable Bun macros (default: false).
--side-effectsbooleanMark package as side-effect free (default: false).

Optimization Features

OptionTypeDescription
--image-optimizationbooleanEnable image optimization (default: false).
--font-optimizationbooleanEnable font optimization (default: false).
--css-optimizationbooleanEnable CSS optimization (default: false).
--performance-monitoringbooleanEnable performance monitoring (default: false).
--bundle-analyzerbooleanEnable bundle analyzer (default: false).
--bundle-size-limit <bytes>numberMaximum bundle size in bytes (default: unlimited).
--performance-budget <json>stringPerformance budget configuration (JSON format).

Build Features

Special Options

OptionTypeDescription
--no-bundlebooleanDisable bundling (transpile only) (default: false).
--cachebooleanEnable build cache (default: true).
--no-cachebooleanDisable build cache (default: false).
--verbosebooleanVerbose mode (default: false).

Post-build Operations

OptionTypeDescription
--replace-exportsbooleanReplace exports from ./dist/.js to ./src/.ts after build (default: false).
--replace-exports-ignore-packages <packages>stringPackages to ignore when replacing exports (supports glob patterns like @reliverse/*).
--logger-clear-internalsbooleanRemove logger.internal() and logInternal() calls from built dist files (default: false).
--logger-clear-internals-ignore-packages <packages>stringPackages to ignore when clearing logger internals (supports glob patterns like @reliverse/*).

Configuration

OptionTypeDescription
--max-config-depth <number>numberMaximum depth to search for dler.ts config files (default: 3).
--kind <type>stringPackage kind: app or library (default: auto-detect).
--allow-private-build <pattern>stringAllow building packages with private: true in package.json. Can be a package name pattern or comma-separated patterns.

Debugging

OptionTypeDescription
--debug-dump-server-filesbooleanDump server files for debugging (default: false).
--debug-no-minifybooleanDisable minification for debugging (default: false).
--throwbooleanThrow on build errors instead of returning success: false.

Examples

Basic Builds

# Build all packages
dler build

# Build specific packages
dler build --filter "@reliverse/ui,@reliverse/utils"

# Skip specific packages
dler build --ignore "@reliverse/docs"

Preset Builds

# Production build
dler build --production

# Development build with watch
dler build --dev

# Library build
dler build --library

# React app build
dler build --react

# Node.js library build
dler build --node

Custom Builds

# Custom entry and output
dler build --entry src/index.ts --outdir dist

# Multiple entries
dler build --entry "src/index.ts,src/cli.ts"

# Specific target and format
dler build --target node --format cjs

# With sourcemaps
dler build --sourcemap linked

# Minified build
dler build --minify

Advanced Builds

# Standalone executable
dler build --compile --targets "linux-x64,darwin-arm64"

# With external dependencies
dler build --external "react,react-dom"

# Development server
dler build --dev-server --port 3001 --open

# With type checking
dler build --type-check --generate-types

Watch & Development

# Watch mode
dler build --watch

# Development build with hot reload
dler build --dev --react-fast-refresh

# No screen clearing in watch
dler build --watch --no-clear-screen

Build Configuration

Build behavior is controlled by dler.ts configuration files. The system searches for these files starting from the current directory up to the specified maximum depth.

Example configuration:

export default defineConfig({
  build: {
    entries: ['src/index.ts'],
    outDir: 'dist',
    target: 'bun',
    format: 'esm',
    minify: true,
  }
})

Build Cache

By default, builds are cached to improve performance. The cache can be disabled with --no-cache or cleared by deleting the cache directory.

Post-build Operations

Export Replacement

Replace package.json exports from built files back to source files:

dler build --replace-exports

Logger Cleanup

Remove internal logger calls from production builds:

dler build --logger-clear-internals

Error Handling

The build command collects errors from all packages by default. Use --stop-on-error to fail fast on the first error. Use --verbose for detailed error information.

Requirements

  • Bun runtime: This command requires Bun to be available
  • Valid workspace: Must be run in a monorepo root or package directory

On this page