-
node 14.x with ECMAScript Modules -> use
import/exportinstead ofrequireandmodule.exports, having a pretty much modern code! Here's how -
lerna -> main monorepo managing tool. Hoist packages, run commands in parallel through packages etc.
-
yarn -> Manage packages. With
yarn workspacesworking together withlerna, we can have a single lockfile in the project root to manage all packages inside the repo. -
jest -> Testing Tool
-
github actions -> CI/CD
-
codecov -> quality assurance
You'll need to have installed:
- node
>= v14.15.5(I prefer to use nvm) - lerna (
npm install -g lerna) - yarn (
npm install -g yarn)
Optionally:
- dbaeumer.vscode-eslint
- esbenp.prettier-vscode
lerna bootstrapwill install all packages dependencies in the root of the monorepo and with a single lockfile.lerna run script-name-> it will execute a command in every package that has this command in thescriptstag. It can belint,testor whatever command you have on the package.lerna create ${package-name} packages/lambda --yeswill create a package calledpackageNameinside the specified folder. The--yesflag will skip the otherpackage.jsoninitprompts.lerna add @config/eslint-config-monorepo --scope=@lambda/example-function-> adds@config/eslint-config-monorepoto@lambda/example-functionYou can only add one package per time, but you can specify more than one scope with brackets expansions like--scope=@lambda/{example-function,other-function}.
I really hate that file being there. I tried to decrease as much as I could the number of configuration files inside each package, but that's
a hard task in some cases.
The reason is just because the VSCode's ESLint extension tries to find a .gitignore file in each directory that it is running. We are
using "mode": "auto" with eslint.workingDirectories to automatically handle each package depending on where the .eslintrc.json file is
(see here).
So to have codeActionsOnSave and all VSCode's ESLint stuff working, we need a .gitignore in each package.
PS: codeActionsOnSave formats your code when you save a file. Very useful since we are using ESLint with Prettier.
Because we are using ECMAScript Modules and Jest needs that extra configuration to work with it. see here
Please LMK!