esbuild macOS 64-bit Binary

0.15.18 · active · verified Wed Apr 22

esbuild is an extremely fast, next-generation JavaScript and CSS bundler and minifier, written in Go. This `esbuild-darwin-64` package provides the specific macOS 64-bit binary, acting as a platform-specific dependency for the main `esbuild` package. The project is actively maintained with frequent releases, currently at stable version `0.28.0`. Key differentiators include its exceptional speed, achieved through parallel parsing, printing, and source map generation, and its robust API for both JavaScript and Go. It supports ES6 and CommonJS modules, TypeScript, JSX, source maps, and minification, making it a versatile tool for modern web development.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically use esbuild's `build` API to bundle a TypeScript file, apply minification, generate sourcemaps, and define environment variables.

import { build } from 'esbuild';
import path from 'path';
import { fileURLToPath } from 'url';
import { dirname } from 'path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

// Create a dummy input file
import fs from 'fs';
const inputTs = `
  interface User { id: number; name: string; }
  const user: User = { id: 1, name: 'Alice' };
  console.log(`Hello, ${user.name}!`);
  export { user };
`;
const inputFilePath = path.join(__dirname, 'src', 'main.ts');
const outputDirPath = path.join(__dirname, 'dist');

fs.mkdirSync(path.join(__dirname, 'src'), { recursive: true });
fs.writeFileSync(inputFilePath, inputTs);

async function runBuild() {
  try {
    await build({
      entryPoints: [inputFilePath],
      bundle: true,
      outdir: outputDirPath,
      platform: 'node',
      format: 'esm',
      target: 'es2022',
      minify: true,
      sourcemap: true,
      logLevel: 'info',
      banner: { js: '// Built with esbuild' },
      define: { 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV ?? 'development') },
    });
    console.log(`
Build successful! Output in: ${outputDirPath}`);
    console.log('Generated file content:');
    console.log(fs.readFileSync(path.join(outputDirPath, 'main.js'), 'utf-8'));
  } catch (e) {
    console.error('Build failed:', e);
    process.exit(1);
  }
}

runBuild();

view raw JSON →