Skip to content

A template project for developing & publishing TypeScript packages

Notifications You must be signed in to change notification settings

StyleShit/create-typescript-package

Repository files navigation

Create TypeScript Package

A template project for developing & publishing TypeScript packages.

Configuration

  1. Replace the package name, description, author, license, etc. in the package.json with your package's details

  2. Update this README.md file to contain your package's documentation

  3. 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}/')
  4. Configure GITHUB_TOKEN to have the permissions to create Pull Requests:

    1. Go to https://github.com/{owner}/{repo}/settings/actions
    2. Check "Allow GitHub Actions to create and approve pull requests" under "Workflow permissions"
  5. Add NPM_TOKEN to your Repository secrets:

    1. Go to NPM's Access Tokens page
    2. Click "Generate New Token" -> "Classic Token" and follow the instructions (make sure to choose "Automation" for the token type)
    3. Go to https://github.com/{owner}/{repo}/settings/secrets/actions, and add the generated token as a secret named NPM_TOKEN

Structure

  • src/ - TypeScript source files
  • **/__tests__/ - Test files
  • dist/ - Compiled JavaScript files

Tools

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.

Development Flow

  1. Add your code & tests to the src/ directory

  2. Use npm run test to run the tests

  3. Use npm run lint to lint the code

  4. Use npm run format to format the code

  5. Use npm run build to build the package

  6. Run npx changeset each time you want to add a commit to the changelog (see Using Changesets for more info)

  7. Commit & push your changes

  8. The CI will automatically open a PR with the changes, or add the changes to an existing PR

  9. Review & merge the PR when you're ready to publish the package

About

A template project for developing & publishing TypeScript packages

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published