gentleeduck/duck-ui / .claude/skills/tsdown
tsdown
VerifiedBundle TypeScript and JavaScript libraries with blazing-fast speed powered by Rolldown. Use when building libraries, generating type declarations, bundling for multiple formats, or migrating from tsup.
references/option-entry.md
View on GitHub# Entry Points
Configure which files to bundle as entry points.
## Overview
Entry points are the starting files for the bundling process. Each entry point generates a separate bundle.
## Usage Patterns
### CLI
```bash
# Single entry
tsdown src/index.ts
# Multiple entries
tsdown src/index.ts src/cli.ts
# Glob patterns
tsdown 'src/*.ts'
```
### Config File
#### Single Entry
```ts
export default defineConfig({
entry: 'src/index.ts',
})
```
#### Multiple Entries (Array)
```ts
export default defineConfig({
entry: ['src/entry1.ts', 'src/entry2.ts'],
})
```
#### Named Entries (Object)
```ts
export default defineConfig({
entry: {
main: 'src/index.ts',
utils: 'src/utils.ts',
cli: 'src/cli.ts',
},
})
```
Output files will match the keys:
- `dist/main.mjs`
- `dist/utils.mjs`
- `dist/cli.mjs`
## Glob Patterns
Match multiple files dynamically using glob patterns:
### All TypeScript Files
```ts
export default defineConfig({
entry: 'src/**/*.ts',
})
```
### Exclude Test Files
```ts
export default defineConfig({
entry: ['src/*.ts', '!src/*.test.ts'],
})
```
### Object Entries with Glob Patterns
Use glob wildcards (`*`) in both keys and values. The `*` in the key acts as a placeholder replaced with the matched file name (without extension):
```ts
export default defineConfig({
entry: {
// Maps src/foo.ts → dist/lib/foo.js, src/bar.ts → dist/lib/bar.js
'lib/*': 'src/*.ts',
},
})
```
#### Negation Patterns in Object Entries
Values can be an array with negation patterns (`!`):
```ts
export default defineConfig({
entry: {
'hooks/*': ['src/hooks/*.ts', '!src/hooks/index.ts'],
},
})
```
Multiple positive and negation patterns:
```ts
export default defineConfig({
entry: {
'utils/*': [
'src/utils/*.ts',
'src/utils/*.tsx',
'!src/utils/index.ts',
'!src/utils/internal.ts',
],
},
})
```
**Warning:** Multiple positive patterns in an array value must share the same base directory.
### Mixed Entries
Mix strings, glob patterns, and object entries in an array:
```ts
export default defineConfig({
entry: [
'src/*',
'!src/foo.ts',
{ main: 'index.ts' },
{ 'lib/*': ['src/*.ts', '!src/bar.ts'] },
],
})
```
Object entries take precedence when output names conflict.
### Windows Compatibility
Use forward slashes `/` instead of backslashes `\` on Windows:
```ts
// ✅ Correct
entry: 'src/utils/*.ts'
// ❌ Wrong on Windows
entry: 'src\\utils\\*.ts'
```
## Common Patterns
### Library with Main Export
```ts
export default defineConfig({
entry: 'src/index.ts',
format: ['esm', 'cjs'],
dts: true,
})
```
### Library with Multiple Exports
```ts
export default defineConfig({
entry: {
index: 'src/index.ts',
client: 'src/client.ts',
server: 'src/server.ts',
},
format: ['esm', 'cjs'],
dts: true,
})
```
### CLI Tool
```ts
export default defineConfig({
entry: {
cli: 'src/cli.ts',
},
format: ['esm'],
platform: 'node',
})
```
### Preserve Directory Structure
Use with `unbundle: true` to keep file structure:
```ts
export default defineConfig({
entry: ['src/**/*.ts', '!**/*.test.ts'],
unbundle: true,
format: ['esm'],
dts: true,
})
```
This will output files matching the source structure:
- `src/index.ts` → `dist/index.mjs`
- `src/utils/helper.ts` → `dist/utils/helper.mjs`
## Tips
1. **Use glob patterns** for multiple related files
2. **Use object syntax** for custom output names
3. **Exclude test files** with negation patterns `!**/*.test.ts`
4. **Combine with unbundle** to preserve directory structure
5. **Use named entries** for better control over output filenames
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |