Monorepo management is a basic functionality of the project. On current project we use pnpm
and nx
:
App centric repositories are used mainly for developing applications and products. This is a common setup in companies. Such repos are characterized in having separate apps
and libs
folder, where the apps
folder contains the buildable and deployable applications, while the libs
folder contains libraries that are specific to one or multiple applications that are being developed within the monorepo.
- applications names are standard kebab-lowercase without special characters
- libraries names must be standard kebab-lowercase with
~
preceding the name
One of the main benefits of adding nx to our pnpm workspace is speed via computation caching. Adding operations to nx caching is performed in nx.json
in root dir. cacheableOperations
array should contain only operations, which are side-effect free.
npm i -g pnpm
- install pnpm globally (check other options in pnpm doc)pnpm add nx -D -w
- add NX to root monorepo workspacepnpm --filter <app-name> <command>
- run command for the application from root folderpnpm add --filter ~iotcon-sdk typescript -D
- install dependency to sdk lib from root folderpnpm add ~iotcon-sdk --filter api-gateway --workspace
- add sdk lib as dependency to api gateway application from current workspacepnpm run -r build
- run command recursivelypnpm install
- if in root installs all dependencies for the projectnpx nx run-many --target=build --projects=api-gateway,~iotcon-sdk
- run specificied projects from root folder (npx is used to run directly from node_modules)