@jmlweb/tsup-config-base
v2.0.3
Published
Base tsup configuration for jmlweb projects with sensible defaults
Downloads
933
Maintainers
Readme
@jmlweb/tsup-config-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
- 🎯 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
npm install --save-dev @jmlweb/tsup-config-base tsup🚀 Quick Start
Create tsup.config.ts in your project root:
import { createTsupConfig } from '@jmlweb/tsup-config-base';
export default createTsupConfig();💡 Examples
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
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
import { createTsupCliConfig } from '@jmlweb/tsup-config-base';
export default createTsupCliConfig();
// Output: dist/cli.js with a #!/usr/bin/env node shebangCLI 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
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[]
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
createTsupConfig,createTsupCliConfig- HelpersBASE_DEFAULTS,CLI_DEFAULTS- Default valuesTsupConfigOptions,TsupCliConfigOptions,EntryConfig,NodeTarget- TypesOptions- Re-exported from tsup
🎯 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
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
{
"scripts": {
"build": "tsup",
"clean": "rm -rf dist",
"prepublishOnly": "npm run build"
}
}npm run build # Build the package
npm run clean # Clean build output📋 Requirements
- Node.js >= 22.12.0
- tsup >= 8.0.0 (tsup 9 itself requires Node.js >= 22.18.0)
📦 Peer Dependencies
tsup(>=8.0.0)
🔗 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
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
Follow the migration guide.
See the Changelog for version history.
📄 License
MIT
