Configures tsup for zero-config TypeScript library bundling with ESM/CJS output, declarations, and esbuild speed. Use when building TypeScript packages, creating dual ESM/CJS libraries, or publishing to npm.
Configures tsup for zero-config TypeScript library bundling with ESM/CJS output, declarations, and esbuild speed. Use when building TypeScript packages, creating dual ESM/CJS libraries, or publishing to npm.
/plugin marketplace add mgd34msu/goodvibes-plugin/plugin install goodvibes@goodvibes-marketThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/options.mdZero-config TypeScript bundler powered by esbuild for fast library builds.
npm install --save-dev tsup typescript
# Bundle with defaults
npx tsup src/index.ts
# ESM and CJS with declarations
npx tsup src/index.ts --format esm,cjs --dts
# Watch mode
npx tsup src/index.ts --watch
import { defineConfig } from 'tsup';
export default defineConfig({
entry: ['src/index.ts'],
format: ['esm', 'cjs'],
dts: true,
sourcemap: true,
clean: true,
minify: true,
target: 'es2020',
outDir: 'dist',
});
export default defineConfig({
entry: {
index: 'src/index.ts',
utils: 'src/utils/index.ts',
cli: 'src/cli.ts',
},
format: ['esm', 'cjs'],
dts: true,
});
export default defineConfig((options) => ({
entry: ['src/index.ts'],
format: ['esm', 'cjs'],
dts: true,
minify: !options.watch,
sourcemap: options.watch,
clean: !options.watch,
}));
{
"name": "my-library",
"version": "1.0.0",
"type": "module",
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": ["dist"],
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"prepublishOnly": "npm run build"
}
}
{
"name": "my-cli",
"version": "1.0.0",
"type": "module",
"bin": {
"my-cli": "./dist/cli.js"
},
"files": ["dist"],
"scripts": {
"build": "tsup src/cli.ts --format esm --target node18"
}
}
export default defineConfig({
// Single entry
entry: ['src/index.ts'],
// Multiple entries
entry: ['src/index.ts', 'src/cli.ts'],
// Named entries
entry: {
index: 'src/index.ts',
cli: 'src/cli.ts',
},
// Glob patterns
entry: ['src/**/*.ts'],
});
export default defineConfig({
format: [
'esm', // ES modules (.mjs)
'cjs', // CommonJS (.cjs)
'iife', // Browser global
],
// Global name for IIFE
globalName: 'MyLibrary',
});
export default defineConfig({
dts: true,
// Or with options
dts: {
resolve: true, // Resolve external types
entry: 'src/index.ts',
compilerOptions: {
strict: true,
},
},
// Only declarations (no JS)
dts: { only: true },
});
export default defineConfig({
// Bundle dependencies (default: false)
bundle: true,
// External packages (not bundled)
external: ['react', 'react-dom', /^@radix-ui/],
// Don't bundle any dependencies
noExternal: [],
// Skip node_modules
skipNodeModulesBundle: true,
});
export default defineConfig({
entry: ['src/index.ts', 'src/utils.ts'],
format: ['esm'],
// Enable code splitting
splitting: true,
// Chunk naming
chunkNames: '[name]-[hash]',
});
export default defineConfig({
minify: true,
// Or use terser for better minification
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
},
},
});
export default defineConfig({
// Browser targets
target: ['es2020', 'chrome90', 'firefox88'],
// Node.js target
target: 'node18',
// Platform
platform: 'browser', // or 'node', 'neutral'
});
export default defineConfig({
define: {
'process.env.NODE_ENV': JSON.stringify('production'),
},
// Replace with env values
env: {
API_URL: 'https://api.example.com',
},
});
export default defineConfig({
// Add shims for ESM/CJS interop
shims: true,
// CJS interop for __dirname, require, etc.
cjsInterop: true,
});
export default defineConfig({
banner: {
js: '/* My Library v1.0.0 */',
css: '/* Styles */',
},
footer: {
js: '/* End of bundle */',
},
});
export default defineConfig({
entry: ['src/cli.ts'],
format: ['esm'],
// Add shebang for CLI
banner: {
js: '#!/usr/bin/env node',
},
});
export default defineConfig({
// Auto-import React
inject: ['./react-shim.js'],
});
// react-shim.js
import * as React from 'react';
export { React };
export default defineConfig({
sourcemap: true, // External .map files
// sourcemap: 'inline', // Inline source maps
});
export default defineConfig({
watch: ['src/**/*.ts'],
// Ignore patterns
ignoreWatch: ['**/*.test.ts', 'node_modules'],
// Callback on rebuild
onSuccess: 'node dist/index.js',
});
export default defineConfig({
esbuildPlugins: [
{
name: 'my-plugin',
setup(build) {
build.onLoad({ filter: /\.txt$/ }, async (args) => {
return {
contents: `export default ${JSON.stringify(await fs.readFile(args.path, 'utf8'))}`,
loader: 'js',
};
});
},
},
],
// esbuild options
esbuildOptions(options) {
options.jsx = 'automatic';
options.jsxImportSource = 'react';
},
});
export default defineConfig({
loader: {
'.png': 'file',
'.svg': 'dataurl',
'.json': 'json',
},
});
export default defineConfig({
entry: ['src/index.ts'],
format: ['esm', 'cjs'],
dts: true,
sourcemap: true,
clean: true,
// Don't bundle React
external: ['react', 'react-dom'],
// JSX
esbuildOptions(options) {
options.jsx = 'automatic';
},
});
export default defineConfig({
entry: ['src/index.ts'],
format: ['esm', 'cjs'],
dts: true,
target: 'node18',
platform: 'node',
clean: true,
// Don't bundle native modules
external: ['fsevents'],
});
export default defineConfig({
entry: ['src/cli.ts'],
format: ['esm'],
target: 'node18',
platform: 'node',
// Bundle everything for standalone CLI
noExternal: [/.*/],
// Shebang
banner: {
js: '#!/usr/bin/env node',
},
minify: true,
});
export default defineConfig([
// Main library
{
entry: ['src/index.ts'],
format: ['esm', 'cjs'],
dts: true,
},
// CLI
{
entry: ['src/cli.ts'],
format: ['esm'],
banner: { js: '#!/usr/bin/env node' },
},
]);
# Basic build
tsup src/index.ts
# With options
tsup src/index.ts --format esm,cjs --dts --minify
# Watch mode
tsup src/index.ts --watch
# Clean before build
tsup src/index.ts --clean
# Specific outDir
tsup src/index.ts --out-dir lib
# Run command on success
tsup src/index.ts --watch --onSuccess "node dist/index.js"
See references/options.md for complete option reference.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.