TypeScript Library Publishing taste
# TypeScript Library Publishing taste of a maintainer who ships small, well-typed npm packages - Publish ESM first and add a CommonJS build only when real consumers still need require(). Confidence: 0.80 - Define entry
Works with
claude-code (compatible), claude (compatible), codex (compatible), chatgpt (compatible), gemini-cli (compatible), cursor (compatible), copilot (compatible), opencode (compatible), amp (compatible), roo (compatible), kiro (compatible), goose (compatible), junie (compatible), trae (compatible), cline (compatible), continue (compatible), antigravity (compatible), windsurf (compatible), augment (compatible), qwen-code (compatible), aider (compatible)
Content
TypeScript Library Publishing taste of a maintainer who ships small, well-typed npm packages
- Publish ESM first and add a CommonJS build only when real consumers still need
require(). Confidence: 0.80 - Define entry points with the
exportsmap and keepmain/typesonly as fallbacks for old tooling. Confidence: 0.90 - Put
typesconditions first inside eachexportsentry so TypeScript resolves declarations correctly. Confidence: 0.85 - Build with tsup or tsdown for bundles and plain
tsc --emitDeclarationOnlyfor.d.tsfiles. Confidence: 0.75 - Turn on
strict,noUncheckedIndexedAccessandexactOptionalPropertyTypesin the library's own tsconfig. Confidence: 0.85 - Check the published package with
publintand@arethetypeswrong/cliin CI before every release. Confidence: 0.90 - Whitelist shipped files with the
filesfield instead of maintaining an.npmignore. Confidence: 0.90 - Set
"sideEffects": falsewhen it is true so bundlers can tree-shake unused exports. Confidence: 0.85 - Export named functions only; avoid default exports so imports stay consistent across ESM and CJS. Confidence: 0.80
- Keep runtime dependencies near zero and move framework packages to
peerDependencies. Confidence: 0.90 - Declare a supported Node.js range in
enginesand test that range in a CI matrix. Confidence: 0.80 - Treat exported types as public API: changing or removing them is a breaking change under semver. Confidence: 0.95
- Mark internal helpers with
@internaland strip them withstripInternalso they don't leak into declarations. Confidence: 0.70 - Write TSDoc comments on every public export, including an
@examplethat compiles. Confidence: 0.80 - Test against the built output, not only the source, so broken
exportspaths fail in CI. Confidence: 0.85 - Add type-level tests with
expectTypeOfortsdfor generics and overloads. Confidence: 0.80 - Manage versions and changelogs with Changesets, and release from CI rather than a laptop. Confidence: 0.85
- Publish with npm provenance enabled and use a granular automation token scoped to the package. Confidence: 0.85
- Ship source maps and declaration maps so "go to definition" lands on real TypeScript source. Confidence: 0.75
- Never rely on
postinstallscripts; a library should install without running code. Confidence: 0.90 - Keep the README's first screen to install, a minimal example and a link to full docs. Confidence: 0.80
Source and license
- Source
- Prompts Chat
- Original
- f/awesome-chatgpt-prompts/prompts.csv#typescript-library-publishing-taste
- License
- MIT