Modules, Runtime & Tooling
Publishing Packages
Publishing a JS/TS package means defining runtime entrypoints, type entrypoints, dependency boundaries, exports, files, versioning, compatibility, and consumer expectations.
- Package exports define the public surface
- Declarations must match emitted JavaScript
- Peer dependencies express host-provided packages
- Files should be intentionally published
- Semver is a communication tool
{
"name": "@acme/utils",
"version": "1.0.0",
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
},
"files": ["dist"]
}| Concern | Question |
|---|---|
| Entrypoints | What can consumers import? |
| Types | Do declarations match emitted JS? |
| Dependencies | Which packages are runtime, dev, peer? |
| Files | What actually gets published? |
| Module format | ESM, CJS, or both? |
| Versioning | Is this change breaking? |
| Consumer tests | Did a real consuming project import it? |