My template for creating npm packages using typescript.
- TS to JS
- Testing via Jest, includes coverage
- ESLint
- Ignore files to ensure minimal code is stored/shipped
NPM link: @el3um4s/typescript-npm-package-starter
To create a new project based on this template using degit:
npx degit el3um4s/typescript-npm-package-starterThen install the dependencies with
npm installNow update the name field in package.json with your desired package name. Then update the homepage field in package.json. And finally add your code.
Run
npm run buildYou can test the code with Jest
npm testYou can find the test coverage in coverage/lcov-report/index.html.
You can check and upgrade dependencies to the latest versions, ignoring specified versions. with npm-check-updates:
npm run check-updatesYou can also use npm run check-updates:minor to update only patch and minor.
Instead npm run check-updates:patch only updates patch.
First commit the changes to GitHub. Then login to your NPM account (If you don’t have an account you can do so on https://www.npmjs.com/signup)
npm loginThen run publish:
npm publishIf you're using a scoped name use:
npm publish --access publicTo update the package use:
npm version patchand then
npm publishTo use the package in a project:
npm i @el3um4s/typescript-npm-package-starterand then in a file:
import { ciao } from "@el3um4s/typescript-npm-package-starter";
const b = ciao("mondo");
console.log(b); // Ciao Mondo