Builderz
Builderz is a zero-configuration JavaScript and TypeScript bundler designed for simplicity and efficiency, aiming to streamline the build process for both libraries and applications by minimizing setup overhead. The current stable version is `0.11.0`, with a development cadence that sees frequent minor updates and patch releases, typically addressing dependency updates, performance enhancements like caching, and bug fixes. Key differentiators include its 'zero-configuration' approach, the ability to build packages even with invalid `package.json` files (addressing a common development pain point), support for parallel build tasks for improved performance, and a robust caching mechanism introduced in `v0.10.0`. It supports both CommonJS (CJS) and ES Module (ESM) output formats and offers both a Command Line Interface (CLI) and a programmatic API for integration into development workflows.
Common errors
-
Error: Cannot find module 'builderz'
cause The 'builderz' package is not installed or incorrectly referenced in your project's `node_modules`.fixRun `npm install builderz` or `yarn add builderz` to add it to your project's dependencies. Ensure your `package.json` correctly lists it under `devDependencies` or `dependencies`. -
Error: Invalid or missing configuration file
cause The `builderz` command was run without a specified configuration file, or the specified file (`-c`) could not be found or parsed.fixEnsure you have a `builderz.config.js` (or `.ts`) file in your project root, or explicitly point to its location using `builderz build -c ./path/to/builderz.config.js`. Verify the file's syntax for any JavaScript/TypeScript errors. -
Build failed with errors
cause Generic error indicating an issue during the bundling process, often related to syntax errors in source code, missing dependencies, or incorrect plugin configuration.fixExamine the console output for more specific error messages, which will usually pinpoint the problematic file or configuration setting. Check your source code for syntax errors, ensure all imported modules exist, and verify your `builderz.config.js` is valid.
Warnings
- breaking The arguments for the `builderz` CLI and potentially its programmatic API were updated in `v0.9.0`. This might require changes to existing build scripts or configurations.
- gotcha As a 'zero-configuration' bundler, Builderz makes many assumptions by default. While this simplifies setup, it can be less flexible for highly customized build requirements or complex monorepos without explicit configuration overrides.
- gotcha Starting from `v0.10.0`, the internal caching mechanism was switched from using a `Map` to a plain JavaScript object. While this is primarily an internal change, it could theoretically have subtle performance implications or edge-case behaviors in very specific environments or with extremely large projects.
Install
-
npm install builderz -
yarn add builderz -
pnpm add builderz
Imports
- build
const { build } = require('builderz')import { build } from 'builderz' - watch
const { watch } = require('builderz')import { watch } from 'builderz' - defineConfig
import defineConfig from 'builderz'
import { defineConfig } from 'builderz'
Quickstart
{
"name": "my-builderz-app",
"version": "1.0.0",
"type": "module",
"scripts": {
"build": "builderz build -c builderz.config.js",
"start": "node dist/esm/index.js"
},
"devDependencies": {
"builderz": "^0.11.0"
}
}
// builderz.config.js
import { defineConfig } from 'builderz';
export default defineConfig({
entries: ['src/index.js'],
output: {
dir: 'dist',
formats: ['esm', 'cjs'],
fileName: '[name].[format].js'
},
plugins: [],
external: [] // Example: externalize node built-in modules
});
// src/index.js
import path from 'node:path';
import url from 'node:url';
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
console.log(`Hello from Builderz! Running from: ${__dirname}`);