0.1.16 • Published 2 years ago
kb-generator-ts v0.1.16
template-typescript-lib
Project template for Node libraries. Features:
- Hybrid ESM/CJS
- Types: TypeScript
- Tests: Vitest
- Linting: ESLint
- Formatting: Prettier
- Publishing: Dripip
- CI: GitHub Actions
- Dependency Management: Renovate
- Community: Issue Templates
Quick Start
The following will get you a ready to go new repository on GitHub based on this one.
Run:
corepack enable && \ gh repo clone jasonkuhrt/template-typescript-lib <directory> && \ cd <directory> && \ pnpm install && \ pnpm ts-node scripts/bootstrap.tsSetup a repo secret called
NPM_TOKENcontaining an npm token for CI package publishing.
Details
- TypeScript
- ESLint
- Vitest
- Dripip
- Simple succinct friendly low-barrier issue templates
- Prettier
- npm scripts for development lifecycle
- CI with GitHub Actions
- Renovate
- PnPM
- CJS+ESM Hybrid package build
- VSCode Settings
- Readme Table of Contents
- Useful TypeScript Libraries
TypeScript for Type Safety & Productivity
- Optimal settings for the safety of your implementation using
@tsconfig/node16-strictest .tsbuildinfocache setup, output discretely intonode_modules/.cache- Base
tsconfig.jsonshared acrosstests,src, andts-node. Optimal output setup for your users
declarationso your users can power their intellisense with your packages typings.declarationMapenabled to make your published source code be navigated to when your users use "go to definition".package.jsontypeVersionsused to emit only one set of declaration files shared by both CJS and ESM builds.sourceMapenabled to allow your users' tools to base off the source for e.g. stack traces instead of the less informative derived built JS.- Publish
srcwith build files so that jump-to-definition tools work optimally for users.
ts-nodefor running TypeScript scripts/modules.- Setup to use SWC for maximum speed.
ESLint For Linting
- TypeScript integration
- TS type-checker powered eslint checks enabled
- Prettier integration using just
eslint-config-prettier.eslint-plugin-prettieris not used to avoid lint noise and slower run time. Prettier is expected to be run by your IDE and your CI and if really needed you manually viapnpm format. - Setup as a CI check for PRs
- Always display as warning to keep IDE error feedback for TypeScript (CI enforces warnings).
- Auto-fixable import sorting
Vitest for Testing
Just Works :)
Dripip for Releasing
Simple succinct friendly low-barrier issue templates
- Emojis ✈️
- Feature / bug / docs / something-else
- Config to display discussions link right in new issue type listing UI
Prettier for code formatting
- Prisma Labs config preset, 110 line width
- Setup as a CI check for PRs
- VSCode extension in recommended extensions list so that when collaborators open the project they'll get prompted to install it if they haven't already.
- npm script
npm scripts for development lifecycle
cleanto remove cache and build filesbuildthat runscleanbeforehandprepublishOnlythat runsbuildbeforehandformatto quickly runprettierover whole codebaselintto quickly runeslintover whole codebase
CI with GitHub Actions
- Separate trunk and pull-request (PR) workflows.
- Dependency install cache enabled.
- On PR:
- Prettier Check
- Lint Check
- Type Check
- Tests across matrix of mac/linux/windows for Node 14/16
- On trunk:
- Tests across matrix of mac/linux/windows for Node 14/16
- Automated canary release
Renovate configuration
- JSON Schema setup for optimal intellisense
- Group all non-major devDependency updates into single PR (which "chore" conventional commit type)
- Group all major devDependency updates into single PR (with "chore" conventional commit type)
- Group all non-major dependency updates into single PR (with "deps" conventional commit type)
- Each major dependency update in own PR (with "deps" conventional commit type)
PnPM for package management
- Using Corepack. This means the PnPM specified in
package.jsonwill be used. And note this is a PnPM binary shipped with Node now. In a future version of Node you will not need to even opt-in into Corepack. Make sure you've donecorepack enableat least once.
CJS+ESM Hybrid package build
An actually working hybrid CJS/ESM build.
VSCode Settings
- Optimize project search by recursively (ready for monorepo) ignoring
build/*, snapshots, lock files, and more. - On-Save actions for optimal editing experience (e.g. ESLint auto-fix to organize imports automatically)
- List of VSCode extensions that users who open the project will be prompted to install if they don't already.
- Enable
typescript.enablePromptUseWorkspaceTsdkso that oneself and collaborators will get prompted to use the workspace version of TypeScript instead of the one in the editor.
Readme Table of Contents
- Using
markdown-toc
Useful TypeScript Libraries
Here are some TypeScript libraries you might want to use for your new project:
https://github.com/stars/jasonkuhrt/lists/typescript