esbuild-cli

raw JSON →
0.0.1 verified Fri May 01 auth: no javascript

esbuild-cli v0.0.1 provides a real-time esbuild wrapper for CLI applications, enabling fast bundling and transpilation with TypeScript support. It targets Node >=16 and focuses on interactive development workflows. As a very early release (0.0.x), it lacks maturity and should be used with caution. Key differentiators: real-time rebuilds and CLI integration, but alternatives like esbuild's own CLI or tools like tsx are more stable and feature-rich.

error Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
cause Package is ESM-only, but used with require().
fix
Change to import or use dynamic import().
error TypeError: build is not a function
cause Incorrect import of default export vs named export.
fix
Use import { build } from 'esbuild-cli' or import esbuildCli from 'esbuild-cli' then use esbuildCli.build().
error Error: Cannot find module 'esbuild'
cause Missing peer dependency esbuild.
fix
Install esbuild as a dependency: npm install esbuild.
gotcha The package is at version 0.0.1; API surface is unstable and may change without notice.
fix Lock to a specific version and test upgrades carefully.
breaking ESM-only package; require() will throw ERR_REQUIRE_ESM.
fix Use import syntax or dynamic import().
gotcha Node engine requirement is >=16; older versions cause runtime errors.
fix Update Node.js to 16 or later.
deprecated No known deprecation as of version 0.0.1.
npm install esbuild-cli
yarn add esbuild-cli
pnpm add esbuild-cli

Basic usage of the build function to bundle a TypeScript entry point for Node.js. Note: requires Node >=16.

import { build } from 'esbuild-cli';

// Example: bundle a TypeScript file for Node.js
build({
  entryPoints: ['./src/index.ts'],
  outfile: './dist/index.js',
  platform: 'node',
  target: 'node16',
  format: 'esm',
  bundle: true,
}).catch(err => {
  console.error('Build failed:', err);
  process.exit(1);
});