base
> [!WARNING]
> Deprecated and no longer maintained. tsup is maintenance-only and recommends tsdown. Use @jmlweb/tsdown-config-base: same helper API and published file names, with a migration guide.
> Base tsup configuration for jmlweb projects, with sensible defaults for TypeScript libraries and CLIs.
✨ Features
Section titled “✨ Features”- 🎯 Sensible defaults: Pre-configured for TypeScript libraries
- 📦 Dual format: CommonJS and ESM output by default
- 📝 Declarations:
.d.tsgeneration enabled - 🖥️ CLI preset: Shebang support
- 🛠️ Fully typed: Exported option types
📦 Installation
Section titled “📦 Installation”npm install --save-dev @jmlweb/tsup-config-base tsup🚀 Quick Start
Section titled “🚀 Quick Start”Create tsup.config.ts in your project root:
import { createTsupConfig } from '@jmlweb/tsup-config-base';
export default createTsupConfig();💡 Examples
Section titled “💡 Examples”External Dependencies
Section titled “External Dependencies”import { createTsupConfig } from '@jmlweb/tsup-config-base';
export default createTsupConfig({ external: ['@jmlweb/eslint-config-base-js', '@eslint/js', 'eslint'],});Multiple Entries and Extra Options
Section titled “Multiple Entries and Extra Options”import { createTsupConfig } from '@jmlweb/tsup-config-base';
export default createTsupConfig({ entry: { index: 'src/index.ts', utils: 'src/utils/index.ts' }, external: ['commander'], options: { minify: true, sourcemap: true, },});CLI Package
Section titled “CLI Package”import { createTsupCliConfig } from '@jmlweb/tsup-config-base';
export default createTsupCliConfig();// Output: dist/cli.js with a #!/usr/bin/env node shebangCLI with Library API
Section titled “CLI with Library API”import { createTsupCliConfig } from '@jmlweb/tsup-config-base';
export default createTsupCliConfig({ entry: { cli: 'src/cli.ts', index: 'src/index.ts' }, shebang: 'cli', // Only the cli entry gets a shebang external: ['commander'],});📋 Configuration Details
Section titled “📋 Configuration Details”createTsupConfig(options?): Options
Section titled “createTsupConfig(options?): Options”| Option | Type | Default | Description |
|---|---|---|---|
entry |
string[] | Record<string, string> |
['src/index.ts'] |
Entry point files |
format |
('cjs' | 'esm' | 'iife')[] |
['cjs', 'esm'] |
Output formats |
dts |
boolean |
true |
Generate declaration files |
clean |
boolean |
true |
Clean output before build |
outDir |
string |
'dist' |
Output directory |
external |
(string | RegExp)[] |
[] |
Packages to exclude from bundle |
options |
Partial<Options> |
{} |
Additional tsup options to merge |
createTsupCliConfig(options?): Options | Options[]
Section titled “createTsupCliConfig(options?): Options | Options[]”Same options, with format defaulting to ['esm'] and entry to { cli: 'src/cli.ts' }, plus:
| Option | Type | Default | Description |
|---|---|---|---|
target |
NodeTarget |
'node18' |
Node.js target version |
shebang |
boolean | string | string[] |
true |
Shebang on all entries (true) or the named ones |
Returns an array of configs when a selective shebang is used.
Exports
Section titled “Exports”createTsupConfig,createTsupCliConfig- HelpersBASE_DEFAULTS,CLI_DEFAULTS- Default valuesTsupConfigOptions,TsupCliConfigOptions,EntryConfig,NodeTarget- TypesOptions- Re-exported from tsup
🎯 When to Use
Section titled “🎯 When to Use”Do not use for new projects. Use @jmlweb/tsdown-config-base instead.
Only keep this package while you have not yet migrated an existing tsup-based build.
🔧 Extending the Configuration
Section titled “🔧 Extending the Configuration”import { createTsupConfig } from '@jmlweb/tsup-config-base';
export default createTsupConfig({ format: ['esm'], // ESM only dts: false, // No type declarations outDir: 'build', external: ['vitest'], // Peer, workspace and optional dependencies options: { minify: true, splitting: true, target: 'es2022', },});📝 Usage with Scripts
Section titled “📝 Usage with Scripts”{ "scripts": { "build": "tsup", "clean": "rm -rf dist", "prepublishOnly": "npm run build" }}npm run build # Build the packagenpm run clean # Clean build output📋 Requirements
Section titled “📋 Requirements”- Node.js >= 22.12.0
- tsup >= 8.0.0 (tsup 9 itself requires Node.js >= 22.18.0)
📦 Peer Dependencies
Section titled “📦 Peer Dependencies”tsup(>=8.0.0)
🔗 Related Packages
Section titled “🔗 Related Packages”@jmlweb/tsdown-config-base- Successor to this package (recommended)@jmlweb/tsconfig-base- TypeScript configuration@jmlweb/vitest-config- Vitest configuration- tsup - TypeScript bundler powered by esbuild
🔄 Migration Guide
Section titled “🔄 Migration Guide”From 1.x to 2.0.0
Section titled “From 1.x to 2.0.0”Breaking: Node.js >= 22.12.0 is required (18 and 20 are end-of-life).
To @jmlweb/tsdown-config-base
Section titled “To @jmlweb/tsdown-config-base”Follow the migration guide.
See the Changelog for version history.
📄 License
Section titled “📄 License”MIT