Skip to content

Minimal starter repository for a publishable Typescript library

License

Notifications You must be signed in to change notification settings

boilerplatedev/typescript-library-starter

Repository files navigation

typescript-library-starter

Commitizen friendly CI Workflow Bundle Size (Minified) Bundle Size (Minified and Zipped) Dependency Count Tree Shaking

A minimal starter repository for a publishable Typescript library. Uses tools we use and love everyday.

The focus is on making sure the developer experience is the best while building with this library.

Features

  • Git Hooks using Husky that lint and run tests before changes are pushed.
  • Source Code Lint using ESLint and Prettier.
  • Commit Message linting with commitlint. Setup to use the conventional style of commit messages.
  • To help developers automatically write good commit messages, commitizen is fully setup to use the conventional style of commit messages.
    • Additionally, devmoji has been setup to emojify commit messages. These are also setup as a prepare-commit-msg git hook. If you wish to remove it, please update .husky/prepare-commit-msg and package.json.
  • Release with semantic-release. If you use a proper Commit Message format, you'll never have to manually version and publish NPM packages again.
  • Test with Jest.
  • Builds using Rollup.
  • GitHub Action to build and release to NPM automatically.

How to Use?

  • Search typescript-library-starter and replace it with your custom package name.

  • Search Abhishek Bhardwaj and replace it with your name.

  • Check .releaserc to enable/disable the semantic-release plugins you may or may not want. The following plugins are initially setup:

  • The Release GitHub Action will automatically generate release notes and a changelog. It will also automatically publish to NPM and also make a TAR ball and add it to GitHub Releases. To use it properly, please generate the following tokens:

    • GITHUB_TOKEN - Generate a Personal Access Token that you can use to authenticate your own user.

      • When using the GITHUB_TOKEN, the minimum required permissions are:

        - `contents`: write to be able to publish a GitHub release
        - `issues`: write to be able to comment on released issues
        - `pull-requests`: write to be able to comment on released pull requests
        
    • NPM_TOKEN - Generate an access token on NPMJS.com to automatically publish the release.

    • This Action is currently setup to run using GitHub Workflows. To learn how to manually run a workflow, checkout this link.

  • To skip CI, add skip ci to commit message.

Helpful Commands

Commands Description
build Uses Rollup to build the source directory and places the output in dist/. Builds both ESM and CJS.
dev:commit Launches an interactive terminal-based commit message writer. Uses commitizen.
dev:open-bundle-visualizer Rollup is configured to generate an HTML file that lets you visualize and analyze your Rollup bundle to see which modules are taking up space in the final exported bundle. The file is rollup-plugin-visualizer-stats.html and this command will automatically open it up in your default browser.
test Runs the Jest based test-suite.
test:ci To run tests in CI environments.
lint Runs ESLint / Prettier to lint source code and display the issues.
format Runs ESLint / Prettier to lint source code and automatically format what can be fixed.
clean Deletes all auto-generated files and cleans up the folder.
typecheck Basically runs tsc with noEmit enabled to check if Typescript has any issues. If there are issues, they're printed on console for the developer to correct.

About

Minimal starter repository for a publishable Typescript library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published