tsdown
Library publishing with tsdown
Building + publishing library packages with tsdown.
MUST
- Build/publish packages with
tsdown. Why: standard ecosystem build. - Emit ESM + declaration files. Why: consumers need types.
prepublishOnlybuilds before publish. Why: never ship staledist/.- Export every type used in the public API. Why: DTS generation fails on unexported internal types leaking through re-exports.
- Test-publish a new package name before wiring the repo to it. Why: npm's name-similarity policy REJECTS a short/common single word at
publish(403Package name too similar to existing packages) even thoughnpm viewsays it is free — the block fires only at publish, so a name that passes availability can still fail. A dashless one-word name has the widest collision surface (leat≈lit/lab/tea1,sigil≈sigil_ both blocked); pick a more distinctive real word (leat→headrace,sigil→escutcheon) and confirm with one throwawaypublishbefore renaming the root, member, repo and every consumer dep. - Retire old versions through
pm4ai cleanup, which the synced release runs on every run, never through a script beside the package. Why: one implementation, holding the release's own token. - Judge an npm version retired by re-reading the registry, never by npm's exit code. Why:
npm unpublishexits 0 and prints- name@versionwhen its write returns 404, as it does for a refused or expired token.
NEVER
- Never bundle a dep the consumer installs itself. Cost: duplicate/version-conflict in consumer tree.