typescript-example-package
Example package for Typescript/Javascript code reuse, includes all the components to publish a package.
Consists of testing, linting, building and deploying of the package.
Usage
Use this repository as a template on the GitHub site and after creating the new project
replace the name typescript-example
of the package to the desired one.
Also, the GitHub links should be updated to the new repository.
The repository name don't have to include the term package
, it's just for the puropse of showing what is the intention of the example.
When setting up the continous integration two environment variables are necessary: NPM_TOKEN
, GH_TOKEN
.
Language
The package uses Typesript becuase the consumers get hints on how to use the library within the sourcecode.
Testing
Jest does the testing as it's not only a testruner, but also includes assertions and a virtual DOM library.
npm run test
npm run test:watch
Linting
Linting is done with ESlint and Prettier because TSlint is no longer maintained.
npm run lint
npm run lint:fix
Bundling
Besides the basic Typescript transpilation, the project uses microbundle
to generate separate optimized files for UMD, module and Node bundles.
npm run bundle
Release
Semantic release enables to generate automatic versions based on commit messages.
By default, the package releases as public, you can change it within package.json
(publishConfig.access
).
npm run release
Installation
To use the package, run the following command in your application folder.
npm install @emartech/typescript-example