Giter Club home page Giter Club logo

typescript-library-starter's Introduction

Example Typescript 4.x Library

Simple starter library updated in 2021.

Tutorial can be found at https://www.tsmean.com/articles/how-to-write-a-typescript-library/.

Usage

First you should get the repo

git clone https://github.com/bersling/typescript-library-starter.git

Then you can apply any changes you'd like to the library-starter.

Give it a name

Adjust the name in library-starter/package.json. Check with npm to see which names are still free.

You can also adjust the version back to 1.0.0 or 0.0.1.

Testing your module locally with npm link

Using npm link you can easily test whether your changes are working correctly.

cd example-consumer
npm run linklib
npm test

Here npm run linklib is just an alias for npm run --prefix ../library-starter build && npm link ../library-starter.

Publishing a beta aka. "next" version

In order not to break things for the users of your library it is a best practice to first publish it with a beta or next tag. That way early adopters or yourself can test some more by using npm install mylib@beta and once you're ready you can publish the actual version npm publish mylib.

Change the version property in library-starter/package.json for example to 2.1.1-beta.1.

cd library-starter
npm run publish-beta

Here npm run publish-beta is an alias for npm run build && npm publish --tag beta.

Then test it through

cd example-consumer
npm run install-beta
npm test

npm run install-beta is an alias for npm install hwrld@beta.

Dry run of publish

It is also a good idea to do a dry run before you publish. That way you can check once more whether the version is correctly specified and you include the correct files.

cd library-starter
npm run publish-dryrun

npm run publish-dryrun is an alias for npm run build && npm publish --dry-run.

Publish a new version

First adjust the version in library-starter/package.json.

Once you are ready to publish an actual version you can run

cd library-starter
npm run publish-lib

npm run publish-lib is an alias for npm run build && npm publish

You can consume it like this:

cd example-consumer
npm run install-lib
npm test

npm run install-lib is equal to npm install hwrld or npm install hwrld@latest.

Further reading

You can write a test like this: https://www.tsmean.com/articles/how-to-write-a-typescript-library/unit-testing

typescript-library-starter's People

Contributors

bersling avatar daniel-taskbase avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.