A minimal, modern TypeScript package template for publishing dual ESM/CJS packages to npm or GitHub Packages.
- pnpm - fast, disk-efficient package manager
- tsup - zero-config bundler powered by esbuild
- TypeScript 6.0+ - strict mode, ESNext target
- GitHub Actions - automated publish workflow
| Format | File |
|---|---|
| ESM | dist/index.js |
| CJS | dist/index.cjs |
| Types | dist/index.d.ts |
Update package.json:
- Set
name- use@username/package-namefor scoped packages (required for GitHub Packages) - Set
version,description,author,repository - Update
publishConfig.registryif publishing to GitHub Packages:"publishConfig": { "registry": "https://npm.pkg.github.com" }
pnpm installAdd your code to src/index.ts. Export everything from here.
| Command | Description |
|---|---|
pnpm dev |
Watch mode - rebuilds on change |
pnpm build |
Production build to dist/ |
pnpm lint |
Type-check without emitting |
pnpm clean |
Remove dist/ |
pnpm build
pnpm publish --access public- Set
nameto@yourusername/package-nameinpackage.json - Set
publishConfig.registrytohttps://npm.pkg.github.com - Add
NODE_AUTH_TOKENto your repository secrets (Settings → Secrets → Actions) - Push to
mainor create a release - the included workflow handles the rest
Add to .npmrc in the consuming project:
@yourusername:registry=https://npm.pkg.github.com
Then install normally:
pnpm add @yourusername/package-nameContributions are welcome. Please read the guidelines before submitting a PR.
This project follows the Contributor Covenant as its Code of Conduct. All participants are expected to adhere to it. Read the full guide to understand what behavior will and won't be tolerated.
Read the contributing guide to learn about the development process, how to propose bug fixes and improvements, and how to build and test your changes.
This project is licensed under the MIT License - you're free to modify, distribute, and use it for any commercial or private project.