Package management with pnpm + workspaces, publishing TypeScript libraries with tsup, building apps with Vite. Apply when setting up a new repo, converting a monorepo, or publishing to npm.
pnpm init
pnpm add -D typescript @types/node
pnpm tsc --init
package.json essentials:
{
"name": "@me/thing",
"version": "0.1.0",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
}
},
"files": ["dist"],
"engines": { "node": ">=22" }
}
Always set "type": "module", "engines.node", and restrict "files"
to what you publish.
# pnpm-workspace.yaml