---
name: ts-library-69cfa6f9572b
description: Use when authoring TypeScript libraries - covers project setup, package exports, build tooling (tsdown/unbuild), API design patterns, type inference tricks, testing, and release workflows. Patterns extracted from 20+ high-quality ecosystem libraries.
license: MIT
---

# TypeScript Library Development

Patterns for authoring high-quality TypeScript libraries, extracted from studying unocss, shiki, unplugin, vite, vitest, vueuse, zod, trpc, drizzle-orm, and more.

## When to Use

- Starting a new TypeScript library (single or monorepo)
- Setting up package.json exports for dual CJS/ESM
- Configuring tsconfig for library development
- Choosing build tools (tsdown, unbuild)
- Designing type-safe APIs (builder, factory, plugin patterns)
- Writing advanced TypeScript types
- Setting up vitest for library testing
- Configuring release workflow and CI

**For Nuxt module development:** use `nuxt-modules` skill

## Quick Reference

| Working on...         | Load file                                                          |
| --------------------- | ------------------------------------------------------------------ |
| New project setup     | [references/project-setup.md](references/project-setup.md)         |
| Package exports       | [references/package-exports.md](references/package-exports.md)     |
| tsconfig options      | [references/typescript-config.md](references/typescript-config.md) |
| Build configuration   | [references/build-tooling.md](references/build-tooling.md)         |
| ESLint config         | [references/eslint-config.md](references/eslint-config.md)         |
| API design patterns   | [references/api-design.md](references/api-design.md)               |
| Type inference tricks | [references/type-patterns.md](references/type-patterns.md)         |
| Testing setup         | [references/testing.md](references/testing.md)                     |
| Release workflow      | [references/release.md](references/release.md)                     |
| CI/CD setup           | [references/ci-workflows.md](references/ci-workflows.md)           |

## Loading Files

**Consider loading these reference files based on your task:**

- [ ] [references/project-setup.md](references/project-setup.md) - if starting a new TypeScript library project
- [ ] [references/package-exports.md](references/package-exports.md) - if configuring package.json exports or dual CJS/ESM
- [ ] [references/typescript-config.md](references/typescript-config.md) - if setting up or modifying tsconfig.json
- [ ] [references/build-tooling.md](references/build-tooling.md) - if configuring tsdown, unbuild, or build scripts
- [ ] [references/eslint-config.md](references/eslint-config.md) - if setting up ESLint for library development
- [ ] [references/api-design.md](references/api-design.md) - if designing public APIs, builder patterns, or plugin systems
- [ ] [references/type-patterns.md](references/type-patterns.md) - if working with advanced TypeScript types or type inference
- [ ] [references/testing.md](references/testing.md) - if setting up vitest or writing tests for library code
- [ ] [references/release.md](references/release.md) - if configuring release workflow or versioning
- [ ] [references/ci-workflows.md](references/ci-workflows.md) - if setting up GitHub Actions or CI/CD pipelines

**DO NOT load all files at once.** Load only what's relevant to your current task.

## Key Principles

- ESM-first: `"type": "module"` with `.mjs` outputs
- Dual format: always support both CJS and ESM consumers
- `moduleResolution: "Bundler"` for modern TypeScript
- tsdown for most builds, unbuild for complex cases
- Smart defaults: detect environment, don't force config
- Tree-shakeable: lazy getters, proper `sideEffects: false`

_Token efficiency: Main skill ~300 tokens, each reference ~800-1200 tokens_


---
Source attribution: Cyber-Security-One
Original project: https://github.com/Cyber-Security-One/security-one-waf-website/blob/afb76a2b38f57c06777a1b28c7397d907671557d/.tessl/tiles/onmax/nuxt-skills/skills/ts-library/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: Cyber-Security-One
Original project: https://github.com/Cyber-Security-One/security-one-waf-website/blob/afb76a2b38f57c06777a1b28c7397d907671557d/.tessl/tiles/onmax/nuxt-skills/skills/ts-library/SKILL.md
Attribution basis: Source repository record

Fields of work: Development & Engineering, Product Management
Roles: Frontend Developer, Backend Developer, Full-Stack Developer, Product Manager, Technical Product Manager
Specialties: API, Backend, Frontend
Tools: GitHub, GitLab, Bitbucket
Country applicability: Country not specified
Classification basis: Source category, role and specialization labels
Instruction SHA-256: 5653e415b9400cab2d17ec6a3b35ff2371230cdc887bf42b80fc97c0a6b100f8
