Example of library/package based on Typescript.
All files from src
folder are imported into the root index.ts
. When you runs build
script Babel will transpile your code using babel.config
and tsc will generate .d.ts
types. All this will be moved to the dist
folder. Now you can publish your library.
- Add your files to the
src
folder. - Run
build
script from package.json or via command line with your package manager: npm run build yarn build pnpm build
Inspect compiled types declarations in the dist folder.
I added files for npm registry. You can safely delete it or replace.
- Login:
npm login
- Publish:
npm publish --access public
NOTE: Sometimes you need to provide login token or something similar. Remember to delete it from your project.
Build
npm run build
Test
npm test
or using watch mode
npm run test:watch
Collect coverage
npm run test:cov
Lint
npm run lint
Format
npm run format