Project template for TypeScript libraries
-
Setup a clone of this repo:
gh repo clone dotindustries/moar-core-ts <your package name> && cd <your package name> && yarn
-
Run the bootstrapper script:
yarn -s bootstrap \ --repoOrg '<your org>/<your repo>' \ --developerName '<your full name>' \ --packageName '<your package name>' \ --createGithubRepo
-
Setup a repo secret called
NPM_TOKEN
containing an npm token for CI package publishing.
Example:
gh repo clone dotindustries/moar-core-ts foobar \
&& cd foobar \
&& yarn \
&& yarn -s bootstrap \
--repoOrg 'dotindustries/foobar' \
--developerName 'Jason Kuhrt' \
--packageName 'foobar' \
--createGithubRepo
-
- Optimal settings for the safety of your implementation
strict
mode enabled.- All lint flags enabled:
.tsbuildinfo
cache setup, output discretely intonode_modules/.cache
- Base
tsconfig.json
shared acrosstests
,src
, andts-node
. ts-patch
setup for enhanced language features:ts-nameof
for pulling the names of identifier down into your runtime!typescript-transform-paths
for a working tsconfigpaths
config!- Tricky
ts-node
configuration taken care of. - Intentional avoidance of
ttypescript
- Optimal output setup for your users
- Target ES2019 which Node as low as version 12 has good support for (kangax compat table).
declaration
so your users can power their intellisense with your packages typings.declarationMap
enabled to make your published source code be navigated to when your users use "go to definition".package.json
typeVersions
used to emit only one set of declaration files shared by both CJS and ESM builds.sourceMap
enabled to allow your users' tools to base off the source for e.g. stack traces instead of the less informative derived built JS.importHelpers
enabled to minimize build size.
- Optimal settings for the safety of your implementation
-
- TypeScript integration
- TS type-checker powered eslint checks enabled
- Prettier integration using just
eslint-config-prettier
.eslint-plugin-prettier
is 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 neeeded you manually viayarn format
. - Setup as a CI check for PRs
- Always display as warning to keep IDE error feedback for TypeScript (CI enforces warnings).
-
jest
for testing- Setup with
ts-jest
- Handy watch mode plugins
jest.config.ts
for type safe & intellisense configuration!typescript-snapshots-plugin
for viewing snapshots on hover of.toMatchSnapshot
method!
- Setup with
-
dripip
for release management -
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
- Emojis
-
Prettier for code formating
- 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
-
- 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
- Config in package.json to disable empty lines between groups.
-
npm scripts for development lifecycle
clean
to remove cache and dist filesbuild
that runsclean
beforehandprepublishOnly
that runsbuild
beforehandformat
to quickly runprettier
andformat-imports
over whole codebaselint
to quickly runeslint
over whole codebase
-
CI with GitHub Actions
- Separate trunk and pull-request (PR) workflows.
- Dependency install cache enabled.
- On PR:
- Prettier Check
- Format Imports Check
- Lint 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 (wich "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)
-
Yarn 1 for package management (mostly for great script runner behaviour)
-
Hybrid package build CJS+ESM (see Dr. Axel's article about this)
- Use
exports
field to give support to both modernimport
and legacyrequire
consumers using Node 12.x and up. For details about theexports
field refer to the Official Node.js Docs about it. - Use
main
field for legacy versions of Node (before12.x
) requiring the CJS build. - Use
module
field for legacy bundlers importing the ESM build.
- Use
-
VSCode Settings
- Optimize project search by ignoring
dist-cjs
/dist-esm
directories. - Enable
typescript.enablePromptUseWorkspaceTsdk
so that oneself and collaborators will get prompted to use the workspace version of TypeScript instead of the one in the editor.
- Optimize project search by ignoring
- Update your GitHub org's label-sync repo to include config for your new repo, assuming your org has such a thing. For example for Prisma Labs: prisma-labs/label-sync.