Skip to content

Files

This branch is 1 commit ahead of, 1585 commits behind ethereumjs/ethereumjs-monorepo:master.

config

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jan 11, 2022
Nov 3, 2021
Sep 13, 2021
Aug 6, 2021
Dec 16, 2021
Nov 24, 2021
Jun 15, 2021
Jun 12, 2021
Jun 12, 2021
Jun 12, 2021
Nov 3, 2021

EthereumJS - Monorepo and Shared Config

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.

Dependencies

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.

Linting

Common linting configuration utilizing:

Exposed CLI commands:

  • ./config/cli/lint.sh
  • ./config/cli/lint-fix.sh

Usage

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",
  }

Getting the most out of linting

This lint package is used as git pre-push hook on with the help of Husky.

Coverage

Tool: nyc

Exposed CLI command:

  • ./config/cli/coverage.sh

Usage

Add .nycrc:

{
  "extends": "../../config/nyc.json"
}

Use scipt above in package.json:

  "scripts": {
    "coverage": "../../config/cli/coverage.sh"
  }

TypeScript

Tool: TypeScript

Exposed CLI commands:

  • ./config/cli/ts-build.sh
  • ./config/cli/ts-compile.sh

Usage

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"
  ]

Documentation

Add typedoc.js to a package that extends the generic TypeDoc configuration:

module.exports = {
  extends: '../../config/typedoc.js',
  // Additional directives
}