Pulled ALL skills from 15 source repositories: - anthropics/skills: 16 (docs, design, MCP, testing) - obra/superpowers: 14 (TDD, debugging, agents, planning) - coreyhaines31/marketingskills: 25 (marketing, CRO, SEO, growth) - better-auth/skills: 5 (auth patterns) - vercel-labs/agent-skills: 5 (React, design, Vercel) - antfu/skills: 16 (Vue, Vite, Vitest, pnpm, Turborepo) - Plus 13 individual skills from various repos Mosaic Stack is not limited to coding — the Orchestrator and subagents serve coding, business, design, marketing, writing, logistics, analysis, and more. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
80 lines
1.8 KiB
Markdown
80 lines
1.8 KiB
Markdown
---
|
|
name: library-development
|
|
description: Building and publishing TypeScript libraries with tsdown. Use when creating npm packages, configuring library bundling, or setting up package.json exports.
|
|
---
|
|
|
|
# Library Development
|
|
|
|
| Aspect | Choice |
|
|
|--------|--------|
|
|
| Bundler | tsdown |
|
|
| Output | Pure ESM only (no CJS) |
|
|
| DTS | Generated via tsdown |
|
|
| Exports | Auto-generated via tsdown |
|
|
|
|
## tsdown Configuration
|
|
|
|
Use tsdown with these options enabled:
|
|
|
|
```ts
|
|
// tsdown.config.ts
|
|
import { defineConfig } from 'tsdown'
|
|
|
|
export default defineConfig({
|
|
entry: ['src/index.ts'],
|
|
format: ['esm'],
|
|
dts: true,
|
|
exports: true,
|
|
})
|
|
```
|
|
|
|
| Option | Value | Purpose |
|
|
|--------|-------|---------|
|
|
| `format` | `['esm']` | Pure ESM, no CommonJS |
|
|
| `dts` | `true` | Generate `.d.ts` files |
|
|
| `exports` | `true` | Auto-update `exports` field in `package.json` |
|
|
|
|
### Multiple Entry Points
|
|
|
|
```ts
|
|
export default defineConfig({
|
|
entry: [
|
|
'src/index.ts',
|
|
'src/utils.ts',
|
|
],
|
|
format: ['esm'],
|
|
dts: true,
|
|
exports: true,
|
|
})
|
|
```
|
|
|
|
The `exports: true` option auto-generates the `exports` field in `package.json` when running `tsdown`.
|
|
|
|
---
|
|
|
|
## package.json
|
|
|
|
Required fields for pure ESM library:
|
|
|
|
```json
|
|
{
|
|
"type": "module",
|
|
"main": "./dist/index.mjs",
|
|
"module": "./dist/index.mjs",
|
|
"types": "./dist/index.d.mts",
|
|
"files": ["dist"],
|
|
"scripts": {
|
|
"build": "tsdown",
|
|
"prepack": "pnpm build",
|
|
"test": "vitest",
|
|
"release": "bumpp -r"
|
|
}
|
|
}
|
|
```
|
|
|
|
The `exports` field is managed by tsdown when `exports: true`.
|
|
|
|
### prepack Script
|
|
|
|
For each public package, add `"prepack": "pnpm build"` to `scripts`. This ensures the package is automatically built before publishing (e.g., when running `npm publish` or `pnpm publish`). This prevents accidentally publishing stale or missing build artifacts.
|