Boilerplate for creating NPM library, config free.
-
Simply
use this template. -
Clone your template locally.
-
Install node dependencies using
pnpm:
pnpm i- Provide
NPM_TOKENrepository secret to GitHub Setting for deployment.
- Create new changeset and follow prompts:
pnpm changeset-
Add pull request to
mainbranch. -
After accepting pull request to
main, a new pull request should be generated viaCD.yml. -
The maintainer needs to accept the new pull request so the package is published.
To achieve consistency for devs, use of pnpm is enforced with a package.json script:
"preinstall": "npx only-allow pnpm"Lint the use of conventional commits with @commitlint/cli.
A helper script pnpm commit is included to guide contributors through commits - czg and cz-git
Includes bug and feature issue templates.
simple-git-hooks is automatically setup on install via a package.json script:
"postinstall": "simple-git-hooks"This repo uses:
biomefor formatting and some linting. Over 95% prettier compatability.eslintfor linting.@eslint/jsplugin for JavaScript rules.typescript-eslintfor TypeScript rules.eslint-plugin-compatfor detecting browser compatability issues.
Note: .npmrc config node-linker=hoisted is necessary to overcome early postinstall bug
CI should work without configuration as long as linting, testing and building are successful.
CD is currectly setup for public release and only publishes on main branch after CI workflow succeeds - refer to .changeset/config.json and .github/workflows/CI.yml.
vitest is designed to be compatable with ECMAScript Modules (ESM), which works directly in browsers. For new libraries this is the recommended method of exporting JavaScript modules.
Does this really matter? - probably not. You can also use jest.
Note: Compatability between browsers and JavaScript runtimes is generally difficult anyways.
Bundling is achieved with tsup and the output format is validated with @arethetypeswrong/cli.