A template project for developing & publishing TypeScript packages.
-
Replace the package name, description, author, license, etc. in the package.json with your package's details
-
Update this README.md file to contain your package's documentation
-
Update the release.yml workflow to check for your username when publishing (this is used to prevent the workflow from running in forks):
if: startsWith(github.repository, '{your-username}/')
-
Configure
GITHUB_TOKEN
to have the permissions to create Pull Requests:- Go to https://github.com/{owner}/{repo}/settings/actions
- Check "Allow GitHub Actions to create and approve pull requests" under "Workflow permissions"
-
Add
NPM_TOKEN
to your Repository secrets:- Go to NPM's Access Tokens page
- Click "Generate New Token" -> "Classic Token" and follow the instructions (make sure to choose "Automation" for the token type)
- Go to https://github.com/{owner}/{repo}/settings/secrets/actions, and add the generated token as a secret named
NPM_TOKEN
src/
- TypeScript source files**/__tests__/
- Test filesdist/
- Compiled JavaScript files
This template uses tsup for transpiling & bundling, Vitest for testing, ESLint & TypeScript ESLint (with the strictest configuration) for linting, Prettier for formatting, and Changesets for versioning & publishing.
-
Add your code & tests to the
src/
directory -
Use
npm run test
to run the tests -
Use
npm run lint
to lint the code -
Use
npm run format
to format the code -
Use
npm run build
to build the package -
Run
npx changeset
each time you want to add a commit to the changelog (see Using Changesets for more info) -
Commit & push your changes
-
The CI will automatically open a PR with the changes, or add the changes to an existing PR
-
Review & merge the PR when you're ready to publish the package