dler build Build workspace packages using configurable bundler
Build all workspace packages using configurable bundler with support for multiple presets, bundlers, and optimization options.
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.
Option Type Description --filter <packages>string Package(s) to include (supports wildcards and comma-separated values like '@reliverse/rempts,@reliverse/build'). Takes precedence over --ignore. --ignore <packages>string Package(s) to ignore (supports wildcards like @reliverse/*). --cwd <path>string Working directory (monorepo root). --concurrency <number>number Number of packages to build concurrently (default: 5). --stop-on-errorboolean Stop on first error instead of collecting all errors (default: false).
Option Short Type Description --entry <file>-estring Entry file (defaults to auto-detect), supports comma-separated multiple entries. --outdir <dir>-ostring Output directory. --outfile <file>string Output filename (for single executable).
Option Type Description --bundler <bundler>string Bundler to use: bun (fast, bundles deps) or mkdist (preserves structure, default for libraries). --target <target>string Build target: browser, bun, or node (default: bun). --runtime <runtime>-r'bun' | 'node'
Option Type Description --compileboolean Generate standalone executable (default: false). --targets <targets>-tstring --compressboolean Compress multi-target builds into tar.gz files (default: false).
Option Type Description --minifyboolean Enable all minification options (default: false). --minify-whitespaceboolean Minify whitespace (default: false). --minify-syntaxboolean Minify syntax and inline constants (default: false). --minify-identifiersboolean Minify variable and function identifiers (default: false).
Option Type Description --splittingboolean Enable code splitting (default: true). --external <packages>string External packages to exclude from bundle (supports wildcards). --packages <mode>string How to handle dependencies: bundle or external (default: bundle).
Option Type Description --format <format>string Output format: esm, cjs, or iife (default: esm). --sourcemap <option>string Sourcemap option: none, linked, inline, or external (default: none).
Option Type Description --watchboolean Watch mode for hot rebuild (default: false). --no-clear-screenboolean Don't clear screen in watch mode (default: false). --react-fast-refreshboolean Enable React Fast Refresh (default: false).
Option Type Description --dev-serverboolean Enable development server (default: false). --port <number>number Development server port (default: 3000). --openboolean Open browser on dev server start (default: false).
Option Type Description --productionboolean Enable production mode (minify=true, sourcemap=none, env=inline). --devboolean Enable development mode (watch=true, sourcemap=linked, env=disable). --libraryboolean Enable library mode (packages=external, bundler=mkdist, generateTypes=true).
Option Type Description --reactboolean Enable React preset (jsx=automatic, target=browser). --nodeboolean Enable Node preset (target=node, format=cjs). --monorepoboolean Enable monorepo preset (concurrency=auto, validateTsconfig=true).
Option Type Description --generate-typesboolean Generate TypeScript declaration files (default: false). --type-checkboolean Run type checking during build (default: false). --validate-tsconfigboolean Validate tsconfig.json for common issues (default: true). --strict-tsconfigboolean Make tsconfig validation errors fatal (default: false). --dts-provider <provider>string DTS generation provider: dts-bundle-generator, api-extractor, typescript, or mkdist (default: dts-bundle-generator).
Option Type Description --env <mode>string Environment variable handling: inline, disable, or prefix like PUBLIC_*. --define <json>string Define global constants (JSON format, e.g., '{"VERSION ":"1.0.0"}').
Option Type Description --public-path <path>string Prefix for import paths in bundled code. --root <path>string Project root for resolving relative paths. --naming <pattern>string Customize output file naming (JSON format). --entry-naming <pattern>string Naming pattern for entry files (e.g., '[dir]/[name].[ext]'). --chunk-naming <pattern>string Naming pattern for chunk files (e.g., '[name]-[hash].[ext]'). --asset-naming <pattern>string Naming pattern for asset files (e.g., '[name]-[hash].[ext]').
Option Type Description --bytecodeboolean Generate bytecode for faster cold starts (requires format: cjs, target: bun). --drop <calls>string Drop function calls (e.g., 'console.log', 'debugger').
Option Type Description --htmlboolean Generate HTML file (default: false). --public-assets <dir>string Public assets directory (default: 'public'). --assets <dir>string Assets directory (default: 'assets').
Option Type Description --appboolean Enable app mode (default: false). --server-componentsboolean Enable server components support (default: false). --css-modulesboolean Enable CSS modules (default: false). --css-chunkingboolean Enable CSS chunking (default: false). --svg-as-reactboolean Convert SVG to React components (default: false). --worker-supportboolean Enable worker support (default: false). --macrosboolean Enable Bun macros (default: false). --side-effectsboolean Mark package as side-effect free (default: false).
Option Type Description --image-optimizationboolean Enable image optimization (default: false). --font-optimizationboolean Enable font optimization (default: false). --css-optimizationboolean Enable CSS optimization (default: false). --performance-monitoringboolean Enable performance monitoring (default: false). --bundle-analyzerboolean Enable bundle analyzer (default: false). --bundle-size-limit <bytes>number Maximum bundle size in bytes (default: unlimited). --performance-budget <json>string Performance budget configuration (JSON format).
Option Type Description --no-bundleboolean Disable bundling (transpile only) (default: false). --cacheboolean Enable build cache (default: true). --no-cacheboolean Disable build cache (default: false). --verboseboolean Verbose mode (default: false).
Option Type Description --replace-exportsboolean Replace exports from ./dist/.js to ./src/ .ts after build (default: false). --replace-exports-ignore-packages <packages>string Packages to ignore when replacing exports (supports glob patterns like @reliverse/*). --logger-clear-internalsboolean Remove logger.internal() and logInternal() calls from built dist files (default: false). --logger-clear-internals-ignore-packages <packages>string Packages to ignore when clearing logger internals (supports glob patterns like @reliverse/*).
Option Type Description --max-config-depth <number>number Maximum depth to search for dler.ts config files (default: 3). --kind <type>string Package kind: app or library (default: auto-detect). --allow-private-build <pattern>string Allow building packages with private: true in package.json. Can be a package name pattern or comma-separated patterns.
Option Type Description --debug-dump-server-filesboolean Dump server files for debugging (default: false). --debug-no-minifyboolean Disable minification for debugging (default: false). --throwboolean Throw on build errors instead of returning success: false.
# Build all packages
dler build
# Build specific packages
dler build --filter "@reliverse/ui,@reliverse/utils"
# Skip specific packages
dler build --ignore "@reliverse/docs"
# 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 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
# 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 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 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 ,
}
})
By default, builds are cached to improve performance. The cache can be disabled with --no-cache or cleared by deleting the cache directory.
Replace package.json exports from built files back to source files:
dler build --replace-exports
Remove internal logger calls from production builds:
dler build --logger-clear-internals
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.
Bun runtime : This command requires Bun to be available
Valid workspace : Must be run in a monorepo root or package directory