agentsclimarketplace

Ts packaging

Skill fusengine/agents/plugins/typescript-expert/skills/ts-packaging

Use when publishing a TypeScript library — exports map, JSR vs npm, dual ESM/CJS, type validation, provenance. Covers modern package.json, jsr.json, and release CI. Do NOT use for application deployment (not a library) or framework build pipelines (use the framework expert's skills).From its SKILL.md

Install
npx -y skills add fusengine/agents --skill ts-packaging

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

3.8 KB, 851 tokens by cl100k_base, as published. Nobody here has run it

TypeScript Packaging

Ship a TypeScript library with a correct exports map, on the right registry.

Agent Workflow (MANDATORY)

Before ANY implementation, use TeamCreate to spawn 3 agents:

  1. fuse-ai-pilot:explore-codebase - Inspect package.json, build output, targets
  2. fuse-ai-pilot:research-expert - Verify latest JSR / npm / Node exports docs via Context7/Exa
  3. mcp__context7__query-docs - Check conditions ordering, attw usage

After implementation, run fuse-ai-pilot:sniper for validation.


Overview

RegistryFormatPublishesBest for
JSRESM onlyTS source directlyDeno/Node/Bun libs, doc-rich APIs
npmESM (or dual ESM/CJS)Built .js + .d.tsBroadest public reach, CJS consumers

Rule of thumb: internal or Bun/Deno/ESM-only consumer → ESM-pure; broad public library still serving CommonJS → dual ESM/CJS.


Critical Rules

  1. "types" first, "default" last - Conditions match in object order
  2. Match import↔ESM and require↔CJS - Never point require at ESM
  3. One subpath per module - Consistent specifier; set "type": "module" explicitly
  4. Validate with attw - arethetypeswrong before every publish
  5. Provenance on public releases - Publish from CI with id-token: write

Decision Guide

Publishing a TS library?
├── Consumers on Deno/Bun/Node ESM, want source + docs → JSR (ESM only)
│   └── Fix "slow types" (explicit return/prop/const types)
└── Public npm audience
    ├── ESM-only consumers → ESM-pure package.json
    └── Some consumers still on CJS → dual ESM/CJS exports

→ See references/exports-map.md for the conditions model


Reference Guide

Concepts

TopicReferenceLoad when
Exports map & conditionsreferences/exports-map.mdWriting the exports field
JSR publishingreferences/jsr-publishing.mdPublishing TS source to JSR
npm publishingreferences/npm-publishing.mdPublishing to npm (dual/ESM)
Type validationreferences/validation.mdChecking types resolve correctly

Templates

TemplateUse Case
references/templates/package-json-dual.mdDual ESM/CJS + ESM-pure package.json
references/templates/jsr-json.mdjsr.json with multi-entry exports
references/templates/publish-workflow.mdGitHub Actions release with provenance

Quick Start

Modern exports (ESM-pure)

{
  "type": "module",
  "exports": {
    ".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" }
  }
}

Validate before publish

npx @arethetypeswrong/cli --pack

→ See references/validation.md


Best Practices

DO

  • Set "type" explicitly, even for CJS packages
  • Provide types in every conditional branch
  • Publish from CI so provenance is automatic

DON'T

  • Ship dual CJS when every consumer is ESM (dead weight)
  • Order "default" before "types" (breaks type resolution)
  • Use --allow-slow-types on JSR as a habit (degrades docs + npm compat)

What ships with it: 8 files

15.3 KB alongside SKILL.md

Keep looking

Skills are one crate of 611,884. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.