0.1.0-next.1 • Published 4 years ago
@blightio/moar v0.1.0-next.1
@moar/core-ts
Project template for TypeScript libraries
Quickstart
Setup a clone of this repo:
gh repo clone blightio/moar-core-ts <your package name> && cd <your package name> && yarnRun the bootstrapper script:
yarn -s bootstrap \ --repoOrg '<your org>/<your repo>' \ --developerName '<your full name>' \ --packageName '<your package name>' \ --createGithubRepoSetup a repo secret called
NPM_TOKENcontaining an npm token for CI package publishing.
Example:
gh repo clone blightio/moar-core-ts foobar \
&& cd foobar \
&& yarn \
&& yarn -s bootstrap \
--repoOrg 'blightio/foobar' \
--developerName 'Jason Kuhrt' \
--packageName 'foobar' \
--createGithubRepoFeatures
- Optimal settings for the safety of your implementation
strictmode enabled.- All lint flags enabled:
.tsbuildinfocache setup, output discretely intonode_modules/.cache- Base
tsconfig.jsonshared acrosstests,src, andts-node. ts-patchsetup for enhanced language features:ts-nameoffor pulling the names of identifier down into your runtime!typescript-transform-pathsfor a working tsconfigpathsconfig!- Tricky
ts-nodeconfiguration 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).
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.importHelpersenabled 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-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 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).
jestfor testing- Setup with
ts-jest - Handy watch mode plugins
jest.config.tsfor type safe & intellisense configuration!typescript-snapshots-pluginfor viewing snapshots on hover of.toMatchSnapshotmethod!
- Setup with
dripipfor 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
- 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
format-imports- 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
cleanto remove cache and dist filesbuildthat runscleanbeforehandprepublishOnlythat runsbuildbeforehandformatto quickly runprettierandformat-importsover 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
- 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
exportsfield to give support to both modernimportand legacyrequireconsumers using Node 12.x and up. For details about theexportsfield refer to the Official Node.js Docs about it. - Use
mainfield for legacy versions of Node (before12.x) requiring the CJS build. - Use
modulefield for legacy bundlers importing the ESM build.
- Use
- VSCode Settings
- Optimize project search by ignoring
dist-cjs/dist-esmdirectories. - Enable
typescript.enablePromptUseWorkspaceTsdkso 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
Tips
- 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.
0.1.0-next.1
4 years ago