0.0.1 • Published 1 year ago

@tanishqkancharla/npm-boilerplate v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

npm-ts-boilerplate

A boilerplate for typescript packages for npm. Esbuild, Api Extractor, Vitest.

# Build into dist folder
npm run build

# Check types and api-extractor
npm run check

npm run test

# Build and publish to NPM (make sure the version is bumped)
npm run release

# Print the bundlesize of the minified package and exit
npm run bundlesize

I've been iterating on this for a while. Here are the interesting bits:

  • Packages are bundled into index.cjs (for CommonJS) and index.js (for ESM).
  • Types are all bundled into index.d.ts
  • Sourcemaps for bundles point to src directory. One could argue the bundles are readable by themselves (since they're not minified), but the source map files are small, and reading in Typescript vs. Javascript can help debug (you know the type of each variable).
  • Only src and dist folders are published to NPM.
  • Tests are in *.test.ts files, run by Vitest
  • API Extractor checks for you that everything you meant to export is exported and everything that was not meant to be exported isn't.

The reason I don't just use Parcel (my preferred build system) is because of:

0.0.1

1 year ago