The starter is built on top of Vite 4.x and prepared for writing libraries in TypeScript. It generates a hybrid package - both support for CommonJS and ESM modules.
- Hybrid support - CommonJS and ESM modules
- IIFE bundle for direct browser support without bundler
- Typings bundle
- ESLint - script linter
- Stylelint - style linter
- Prettier - formatter
- Jest - test framework
- Husky + lint-staged - pre-commit git hook set up for formatting
This is a template repo. Click the green Use this template button to get started.
If you prefer to do it manually with the cleaner git history
git clone https://github.com/kothing/vite-typescript-library-template.git
cd vite-typescript-library-template
npm iWhen you use this template, update the following:
- Remove
.gitdirectory and rungit initto clean up the history - Change the name in
package.json- it will be the name of the IIFE bundle global variable and bundle files name (.cjs,.mjs,.iife.js,d.ts) - Change the author name in
LICENSE - Clean up the
READMEandCHANGELOGfiles
And, enjoy :)
The starter contains the following scripts:
dev- starts dev serverbuild- generates the following bundles: CommonJS (.cjs) ESM (.mjs) and IIFE (.iife.js). The name of bundle is automatically taked frompackage.jsonname propertytest- starts jest and runs all teststest:coverage- starts jest and run all tests with code coverage reporteslint- lint.js,.jsx,.ts,.tsxfiles with eslintprettier- format.js,.ts,.htmland.jsonfiles with prettierstylelint- format.csslessand.scssfiles with stylelintprepare- script for setting up husky pre-commit hook
If you found it useful somehow, I would be grateful if you could leave a star in the project's GitHub repository.
Thank you.