Skip to content

Starter template to create typescript library

License

Notifications You must be signed in to change notification settings

ngekoding/ts-starter-library

Repository files navigation

ts-starter-library

Starter template to create typescript library.

Features

We've already taken care of the configuration so you can dive straight into building your dream library.

  • ESLint: Auto fix for formatting with @antfu/eslint-config.
  • Commitlint: Commit message conventions.
  • Jest: Unit testing.
  • Bumpp: Version management.
  • Output: CommonJS and ESM.

Getting started

  1. Create new repository by clicking Use this template.
  2. Complete creating repository based on the library that will you build like name and description.
  3. Clone the repository to your computer.
  4. Open and modify package.json to fit your library: name, description, author, etc.

Make sure the library name is available on NPM registry. Check it by opening npmjs.com and search for the library name, and if there is no package found, so it is available to use.

The repository name and description is mostly the same as what we use in the package.json, so you can check the availability when creating the repository.

  1. Start building your library

Publishing

Before publishing the library, it is good to make sure the library running well by making a test. You can found the example in test directory.

Publishing to NPM registry needing an account, so if you don't have an account yet, visit the NPM sign up to create one.

  1. Login

Open terminal and run the npm login command.

npm login

Complete the login process as prompted.

  1. Publishing
npm run release

You will prompted to choose the library version. It is good to follow the semantic versioning.

If all goes well, you will get a message telling that the library is successfully published to the NPM registry.

Further more

What we do above is creating unscoped public packages like many general NPM packages. Then you can found detailed about this topic in Contributing packages to the registry.

License

MIT License © 2024-PRESENT Nur Muhammad