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
srcfolder. - Run
buildscript 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 publicNOTE: Sometimes you need to provide login token or something similar. Remember to delete it from your project.
Build
npm run buildTest
npm testor using watch mode
npm run test:watchCollect coverage
npm run test:covLint
npm run lintFormat
npm run format