esbuild
БесплатноБез исполняемых скриптовНе проверенesbuild extremely fast JavaScript bundler. Used internally by Vite. Use for simple bundling, library builds, or understanding Vite internals. USE WHEN: user…
от claude-dev-suite★ 51 звезда на GitHubОб этом скилле
esbuild - Quick Reference
Deep Knowledge: Use
mcp__documentation__fetch_docswith technology:esbuildfor comprehensive documentation.
When NOT to Use This Skill
- Complex applications - Use Vite (which uses esbuild internally)
- Need many plugins - Webpack or Rollup have richer ecosystems
- CSS modules, PostCSS - Vite handles these better
- HMR required - Vite provides full HMR experience
When to Use This Skill
- Ultra-fast simple bundling
- TypeScript library builds
- Understanding how Vite works
- Custom build scripts
Setup
npm install -D esbuild
CLI Usage
# Bundle single file
esbuild src/index.ts --bundle --outfile=dist/bundle.js
# Watch mode
esbuild src/index.ts --bundle --outfile=dist/bundle.js --watch
# Minify for production
esbuild src/index.ts --bundle --minify --outfile=dist/bundle.min.js
# Multiple outputs
esbuild src/index.ts --bundle --outdir=dist --format=esm --format=cjs
# Source maps
esbuild src/index.ts --bundle --sourcemap --outfile=dist/bundle.js
API Usage
// build.ts
import * as esbuild from 'esbuild';
// Simple build
await esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
outfile: 'dist/bundle.js',
});
// Production build
await esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
minify: true,
sourcemap: true,
target: ['es2020'],
outfile: 'dist/bundle.min.js',
});
Configuration Options
await esbuild.build({
// Entry points
entryPoints: ['src/index.ts', 'src/worker.ts'],
// Or object for custom names
entryPoints: {
main: 'src/index.ts',
worker: 'src/worker.ts',
},
// Output
bundle: true,
outdir: 'dist',
outfile: 'dist/bundle.js', // Single file
outExtension: { '.js': '.mjs' },
// Format
format: 'esm', // 'esm' | 'cjs' | 'iife'
platform: 'node', // 'browser' | 'node' | 'neutral'
target: ['es2020', 'chrome90', 'firefox88'],
// Optimization
minify: true,
minifyWhitespace: true,
minifyIdentifiers: true,
minifySyntax: true,
treeShaking: true,
// Source maps
sourcemap: true, // External .map file
sourcemap: 'inline', // Inline in JS
sourcemap: 'linked', // External with reference
// Splitting (ESM only)
splitting: true,
chunkNames: 'chunks/[name]-[hash]',
// External packages
external: ['react', 'react-dom'],
packages: 'external', // All node_modules external
// Define
define: {
'process.env.NODE_ENV': '"production"',
'__VERSION__': '"1.0.0"',
},
// Loaders
loader: {
'.png': 'file',
'.svg': 'text',
'.json': 'json',
},
// Paths
alias: {
'@': './src',
'@components': './src/components',
},
resolveExtensions: ['.tsx', '.ts', '.jsx', '.js'],
// Banner/Footer
banner: {
js: '/* Bundle generated at ' + new Date().toISOString() + ' */',
},
footer: {
js: '/* End of bundle */',
},
// Legal comments
legalComments: 'none', // 'none' | 'inline' | 'eof' | 'linked' | 'external'
// Metafile for analysis
metafile: true,
});
Watch Mode (API)
// Watch with rebuild
const ctx = await esbuild.context({
entryPoints: ['src/index.ts'],
bundle: true,
outfile: 'dist/bundle.js',
});
await ctx.watch();
console.log('Watching for changes...');
// Later: stop watching
await ctx.dispose();
Dev Server
const ctx = await esbuild.context({
entryPoints: ['src/index.tsx'],
bundle: true,
outdir: 'dist',
});
// Start dev server
await ctx.serve({
servedir: 'dist',
port: 3000,
});
console.log('Server running on http://localhost:3000');
Plugins
// Custom plugin structure
const myPlugin: esbuild.Plugin = {
name: 'my-plugin',
setup(build) {
// Resolve hook
build.onResolve({ filter: /^env$/ }, (args) => ({
path: args.path,
namespace: 'env-ns',
}));
// Load hook
build.onLoad({ filter: /.*/, namespace: 'env-ns' }, () => ({
contents: JSON.stringify(process.env),
loader: 'json',
}));
// Start/End hooks
build.onStart(() => {
console.log('Build started');
});
build.onEnd((result) => {
console.log(`Build ended with ${result.errors.length} errors`);
});
},
};
await esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
plugins: [myPlugin],
outfile: 'dist/bundle.js',
});
Common Plugins
// Environment variables plugin
const envPlugin: esbuild.Plugin = {
name: 'env',
setup(build) {
build.onResolve({ filter: /^env$/ }, (args) => ({
path: args.path,
namespace: 'env-ns',
}));
build.onLoad({ filter: /.*/, namespace: 'env-ns' }, () => ({
contents: `export const API_URL = ${JSON.stringify(process.env.API_URL)}`,
loader: 'ts',
}));
},
};
// CSS modules plugin (basic)
const cssModulesPlugin: esbuild.Plugin = {
name: 'css-modules',
setup(build) {
build.onLoad({ filter
Установить esbuild в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobWriteEditBashFAQ
Что делает скилл esbuild?
esbuild extremely fast JavaScript bundler. Used internally by Vite. Use for simple bundling, library builds, or understanding Vite internals. USE WHEN: user mentions "esbuild", "fast bundler", asks about "esbuild config", "library bundling", "esbuild API" DO NOT USE FOR: Complex apps (use Vite), Webpack projects (use webpack skill), need extensive plugins (use Rollup/Webpack)
Как установить скилл esbuild?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл esbuild запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic