https://github.com/boilertown/node-package-boilerplate
A boilerplate with opinionated setup to help you kickstart your own Node.js package.
https://github.com/boilertown/node-package-boilerplate
cjs esm nodejs npm npm-package typescript
Last synced: 3 months ago
JSON representation
A boilerplate with opinionated setup to help you kickstart your own Node.js package.
- Host: GitHub
- URL: https://github.com/boilertown/node-package-boilerplate
- Owner: boilertown
- License: mit
- Created: 2022-08-25T09:58:14.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-01T05:07:40.000Z (over 3 years ago)
- Last Synced: 2025-01-04T05:19:14.165Z (over 1 year ago)
- Topics: cjs, esm, nodejs, npm, npm-package, typescript
- Language: JavaScript
- Homepage:
- Size: 715 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
♨️ Node Package Boilerplate
A boilerplate with opinionated setup to help you kickstart your own Node.js package.
## The Setup
- [TypeScript][typescript-url]
- Linting with [Eslint][eslint-url] and code formatting with [Prettier][prettier-url]
- Conventional commit messages with [Commitlint][commitlint-url]
- Build with [Rollup][rollup-url]
- [Vitest][vitest-url] for Unit test
- Automated release with [changesets][changesets-url]
- Build library for Node.js 14 or newer.
- Support both CJS & ESM.
## Get Started
- Use [Boilertown](https://github.com/boilertown/create-boilertown) CLI.
```sh
# npm
npm create boilertown@latest -- -b node-package-boilerplate
# yarn
yarn create boilertown -b node-package-boilerplate
# pnpm
pnpm create boilertown -b node-package-boilerplate
# bun
bun create boilertown/node-package-boilerplate [package-name]
```
- Click the green "Use this template" button to generate a new repository with the same structure and files.

[Ref: Github Docs](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template)
## Development
- Build the package to release:
```sh
pnpm build
```
- Create changeset:
```sh
pnpm changeset
```
## Release & Publish
This boilerplate uses [changesets][changesets-url] to automatically generate `CHANGELOG`, create releases and publish to NPM registry via GitHub Actions. You can see action details at [release.yml](/.github/workflows//release.yml).
To automating publish your Node.js package, follow these steps:
- Create a `NPM_TOKEN`. [See this article for more details](https://docs.npmjs.com/creating-and-viewing-access-tokens). Make sure the type of access token is **Automation**.
- [Follow this instruction](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) to add the created token to your GitHub Actions secrets. Name of the secret is `NPM_TOKEN`.
- Install [changeset bot](https://github.com/apps/changeset-bot).
- [Adding changeset and commit](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md#i-am-in-a-single-package-repository).
**P/S**: Remember to check the `Allow GitHub Actions to create and approve pull requests` in your repo Settings > Actions > General & scroll to Workflow permissions.
## Contributing
**node-package-boilerplate** ❤️ your contributions. If you have any ideas, suggestions, fixes, feel free to contribute.
[boilertown-url]: https://github.com/boilertown
[typescript-url]: https://www.typescriptlang.org
[eslint-url]: https://eslint.org
[commitlint-url]: https://github.com/conventional-changelog/commitlint
[prettier-url]: https://prettier.io
[changesets-url]: https://github.com/changesets/changesets
[rollup-url]: https://rollupjs.org
[vitest-url]: https://vitest.dev/