This folder contains documentation on monorepo setup and configuration as well as shared
configuration settings and scripts for common modules (like a shared tsconfig.json
TypeScript
configuration file or cli/coverage.sh
script).
- Monorepo (separate docs)
- E2E Testing (separate docs)
- Linting
- Coverage
- TypeScript
- Documentation
The cli scripts (./config/cli
) are used in the child packages' package.json
to ease repetitive script use.
Shared config devDependencies
across all packages can go in the root package.json
. However, if a package needs access to the dependency's bin
(e.g. eslint
or nyc
) then it must be defined in the child packages' package.json
.
Common linting configuration utilizing:
Exposed CLI commands:
./config/cli/lint.sh
./config/cli/lint-fix.sh
Add .eslintrc.js
:
module.exports = {
extends: '../../config/eslint.js',
}
In this file you can add rule adjustments or overrides for the specific package.
Add prettier.config.js
:
module.exports = require('../../config/prettier.config')
Use CLI commands above in your package.json
:
"scripts": {
"lint": "../../config/cli/lint.sh",
"lint:fix": "../../config/cli/lint-fix.sh",
}
This lint package is used as git pre-push hook on with the help of Husky.
Tool: nyc
Exposed CLI command:
./config/cli/coverage.sh
Add .nycrc
:
{
"extends": "../../config/nyc.json"
}
Use scipt above in package.json
:
"scripts": {
"coverage": "../../config/cli/coverage.sh"
}
Tool: TypeScript
Exposed CLI commands:
./config/cli/ts-build.sh
./config/cli/ts-compile.sh
The three files below compose the functionality built into ts-build.sh
and ts-compile.sh
. Note that the browser build is optional, and in the case it's not present in the package, browser builds will be ignored.
Add tsconfig.json
:
{
"extends": "../../config/tsconfig.json",
"include": ["src/**/*.ts", "test/**/*.ts"]
}
Add tsconfig.prod.json
:
{
"extends": "../../config/tsconfig.prod.json",
"include": ["src/**/*.ts"],
"compilerOptions": {
"outDir": "./dist"
}
}
Add tsconfig.browser.json
:
{
"extends": "../../config/tsconfig.browser.json",
"include": ["src/**/*.ts"],
"compilerOptions": {
"outDir": "./dist.browser"
}
}
Note: the outDir
property is mandatory to generate assets to a directory.
Use CLI commands above in your package.json
:
"scripts": {
"tsc": "../../config/cli/ts-compile.sh",
"build": "../../config/cli/ts-build.sh"
}
The default production target is ES2017. To support shipping the ES5 target for browsers, add to your package.json
:
"main": "dist/index.js",
"types": "dist/index.d.ts",
"browser": "dist.browser/index.js",
"files": [
"dist",
"dist.browser"
]
Add typedoc.js
to a package that extends the generic TypeDoc configuration:
module.exports = {
extends: '../../config/typedoc.js',
// Additional directives
}