All skills

Use when bundling TypeScript libraries - provides tsdown configuration, dual ESM/CJS output, .d.ts generation, and plugin authoring

  • 5 files
  • 15.4 KB
  • MIT
  • Updated 8 months ago
  • GitHub

Use this Skill: https://skilld.dev/gh/onmax/claude-config/tsdown

This session only. Nothing lands on disk.

referencesconfig.md

≈787 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Configuration & CLI

Config File

Supported files (searched in order):

  • tsdown.config.ts / .mts / .cts
  • tsdown.config.js / .mjs / .cjs
  • tsdown.config.json
  • tsdown field in package.json
// tsdown.config.ts
import { defineConfig } from 'tsdown'

export default defineConfig({
  entry: 'src/index.ts',
  dts: true,
  exports: true,
})

Multiple Configurations

import { defineConfig } from 'tsdown'

export default defineConfig([
  {
    entry: 'src/node.ts',
    platform: 'node',
  },
  {
    entry: 'src/browser.ts',
    platform: 'browser',
  },
])

Entry Points

// Single entry
defineConfig({
  entry: 'src/index.ts',
})

// Multiple entries
defineConfig({
  entry: ['src/entry1.ts', 'src/entry2.ts'],
})

// Entry aliases → dist/main.js, dist/utils.js
defineConfig({
  entry: {
    main: 'src/index.ts',
    utils: 'src/utils.ts',
  },
})

// Glob patterns
defineConfig({
  entry: 'src/**/*.ts',
})

CLI Commands

tsdown                          # Build
tsdown src/index.ts             # Specify entry
tsdown --watch                  # Watch mode
tsdown -w

tsdown --config ./path/to/config
tsdown --no-config              # Skip config file

CLI Options

# Output
--format esm|cjs|iife|umd
--format esm --format cjs       # Multiple formats
-d ./build                      # Output dir
--out-dir ./build

# Declaration files
--dts

# Target
--target es2020
--target node20
--no-target                     # Preserve modern syntax

# Platform
--platform node|browser|neutral

# Optimization
--minify
--sourcemap
--treeshake
--no-treeshake

# Cleaning
--clean                         # Default: true
--no-clean

# External
--external lodash
--external "@my-scope/*"

# Watch
--watch [path]
--ignore-watch node_modules

# Env
--env.NODE_ENV=production
--env-file .env.production
--env-prefix APP_

# Post-build
--on-success "echo Done!"

# Copy assets
--copy public

# Package exports
--exports

CLI Flag Patterns

--foo              # foo: true
--no-foo           # foo: false
--foo.bar          # foo: { bar: true }
--format esm --format cjs  # format: ['esm', 'cjs']

Config Loaders

tsdown --config-loader auto     # Default
tsdown --config-loader native   # Node.js TypeScript
tsdown --config-loader unrun    # More powerful

Extend Vite/Vitest Config

Reuse resolve and plugins:

tsdown --from-vite              # Load vite.config.*
tsdown --from-vite vitest       # Load vitest.config.*

Common Configurations

Pure ESM Library

defineConfig({
  entry: 'src/index.ts',
  format: 'esm',
  dts: true,
  exports: true,
  target: 'es2020',
})

Dual ESM/CJS

defineConfig({
  entry: 'src/index.ts',
  format: ['esm', 'cjs'],
  dts: true,
  exports: true,
})

Node.js CLI

defineConfig({
  entry: 'src/cli.ts',
  format: 'esm',
  platform: 'node',
  dts: true,
  shims: true,  // __dirname, __filename in ESM
})

Browser Library

defineConfig({
  entry: 'src/index.ts',
  format: ['esm', 'iife'],
  platform: 'browser',
  minify: true,
})

Source: SKILL.md on GitHub

No third-party reports yet.

Signed by skilld at 6a37106. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 12 hours ago.

Activeupdated 8 months ago

README badge

README badge for onmax/claude-config/tsdown