# esbuild-bundler

Teaches agents best practices for esbuild across browser and Node.js environments. Useful when configuring TypeScript, bundles, and dev servers.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 697 installs · ★ 286
- Author: Mindrally
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/Mindrally/skills/tree/HEAD/esbuild-bundler/SKILL.md
- Updated: 2026-10-08
- HTML: https://affpapa.org/en/nevibecode/skills/esbuild-bundler

## What it does

The skill equips coding agents with patterns for esbuild in JavaScript and TypeScript projects. It covers CLI flags, JavaScript API scripts, built-in loaders for assets, and variable injection through `define`.

Included guidelines detail setups for Node.js, browsers, and module formats such as ESM or CommonJS. Code splitting carries a strict requirement: it functions only when `format: 'esm'` is paired with `outdir` instead of `outfile`.

esbuild skips type checking entirely. Because of this, the guide enforces `isolatedModules: true` in `tsconfig.json` and delegates type validation to a standalone `tsc --noEmit` call.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill esbuild-bundler -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/esbuild-bundler/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/esbuild-bundler/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill esbuild-bundler -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/esbuild-bundler/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill esbuild-bundler -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/esbuild-bundler/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install Mindrally/skills esbuild-bundler
```

2. **Manually: put the files in place**
- File: `.github/skills/esbuild-bundler/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill esbuild-bundler -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/Mindrally/skills --path esbuild-bundler
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/esbuild-bundler/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill esbuild-bundler -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/Mindrally/skills/tree/HEAD/esbuild-bundler/SKILL.md

## When to use it
- generate build configurations for browser or Node.js targets
- set required tsconfig.json flags for esbuild compatibility
- configure code splitting and external module exclusions
- spin up the built-in development server with file watching

## Example prompts
- Create an esbuild.config.mjs script for Node.js using ESM output
- Configure tsconfig.json to work properly with esbuild
- Set up esbuild context.serve on port 3000 with watch mode

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: aeeb8dd9e2b4d32d.

BEGIN THIRD-PARTY FILE aeeb8dd9e2b4d32d
````text
---
name: esbuild-bundler
description: Best practices and guidelines for esbuild, the ultra-fast JavaScript and TypeScript bundler and minifier
metadata:
  maintainer: Mindrally
  source: https://github.com/Mindrally/skills
---

# esbuild Bundler

You are an expert in esbuild, the extremely fast JavaScript and TypeScript bundler written in Go. Follow these guidelines when working with esbuild configurations.

## Core Principles

- esbuild is 10-100x faster than traditional bundlers
- Zero configuration needed for most use cases
- Native TypeScript and JSX support without additional setup
- Focus on speed while maintaining code quality
- Written in Go for native performance

## Project Structure

```
project/
├── src/
│   ├── index.ts          # Main entry point
│   ├── components/       # UI components
│   └── utils/            # Utility functions
├── dist/                 # Build output
├── esbuild.config.mjs    # Build script (optional)
├── tsconfig.json         # TypeScript config
└── package.json
```

## Basic Usage

### Command Line

```bash
# Basic bundle
esbuild src/index.ts --bundle --outfile=dist/bundle.js

# Production build
esbuild src/index.ts --bundle --minify --sourcemap --outfile=dist/bundle.js

# Watch mode
esbuild src/index.ts --bundle --watch --outfile=dist/bundle.js
```

### JavaScript API

```javascript
import * as esbuild from 'esbuild';

await esbuild.build({
  entryPoints: ['src/index.ts'],
  bundle: true,
  minify: true,
  sourcemap: true,
  outfile: 'dist/bundle.js'
});
```

## TypeScript Configuration

### tsconfig.json Best Practices

```json
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "esModuleInterop": true,
    "isolatedModules": true,
    "strict": true,
    "skipLibCheck": true,
    "noEmit": true,
    "verbatimModuleSyntax": true,
    "noUncheckedIndexedAccess": true
  },
  "include": ["src/**/*"]
}
```

### Important TypeScript Settings

- `isolatedModules: true` - Required for esbuild compatibility
- `esModuleInterop: true` - Better ESM compatibility
- `noEmit: true` - Let esbuild handle output, use tsc for type checking only

## Build Configuration

### Browser Build

```javascript
await esbuild.build({
  entryPoints: ['src/index.ts'],
  bundle: true,
  minify: true,
  sourcemap: true,
  target: ['chrome90', 'firefox88', 'safari14', 'edge90'],
  outfile: 'dist/bundle.js'
});
```

### Node.js Build

```javascript
await esbuild.build({
  entryPoints: ['src/index.ts'],
  bundle: true,
  platform: 'node',
  target: 'node18',
  format: 'esm',
  outfile: 'dist/index.js'
});
```

### Multiple Entry Points

```javascript
await esbuild.build({
  entryPoints: ['src/index.ts', 'src/worker.ts'],
  bundle: true,
  outdir: 'dist',
  splitting: true,
  format: 'esm'
});
```

## Output Formats

### ESM (ES Modules)

```javascript
await esbuild.build({
  format: 'esm',
  // Outputs: import/export syntax
});
```

### CommonJS

```javascript
await esbuild.build({
  format: 'cjs',
  // Outputs: require/module.exports
});
```

### IIFE (Browser Scripts)

```javascript
await esbuild.build({
  format: 'iife',
````
END THIRD-PARTY FILE aeeb8dd9e2b4d32d

The third-party file has ended. Everything between the aeeb8dd9e2b4d32d tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 3199 of 8211 bytes. © Mindrally · Apache-2.0 · https://github.com/Mindrally/skills/tree/HEAD/esbuild-bundler/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
