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).
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/.c8rc.json"
}
Use script 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 build is browser compatible with ES2020
target.
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"
}
}
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"
}
Add typedoc.js
to a package that extends the generic TypeDoc configuration:
module.exports = {
extends: '../../config/typedoc.js',
// Additional directives
}