-
node 14.x with ECMAScript Modules -> use
import/export
instead ofrequire
andmodule.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 workspaces
working 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 bootstrap
will 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 thescripts
tag. It can belint
,test
or whatever command you have on the package.lerna create ${package-name} packages/lambda --yes
will create a package calledpackageName
inside the specified folder. The--yes
flag will skip the otherpackage.json
init
prompts.lerna add @config/eslint-config-monorepo --scope=@lambda/example-function
-> adds@config/eslint-config-monorepo
to@lambda/example-function
You 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!