A TypeScript library template using Bun.
npx giget gh:bentruyman/templates/bun/lib my-lib
cd my-lib
bun installUpdate package.json with your project details:
name- Your package namedescription- What your library doesexports- The entrypoints you want to publish
Replace the example implementation in src/index.ts with your library code.
| Script | Description |
|---|---|
bun run build |
Build the library with package deps external |
bun run check:dist |
Verify dist/index.js size and import shape |
bun run format |
Format code with oxfmt |
bun run format:check |
Check formatting without rewriting files |
bun run lint |
Lint the template with oxlint |
bun run typecheck |
Type-check with TypeScript |
bun run verify |
Run format, lint, typecheck, test, and build |
bun run release |
Publish a new version with release-it |
Run tests while iterating:
bun test --watchFor normal npm-published packages, keep runtime dependencies external:
bun build src/index.ts --outdir dist --target node --packages externalUse Bun's default bundled mode only when you explicitly want a single-file
distribution artifact. If a dependency stays in package.json, do not inline it
into the published build by default.
- Update
package.jsonname and exports fields - Run
bun run releaseto build, tag, and publish to npm