This repository shows a simple way to create a monorepo (where X applications can use a shared package - e.g. for shared UI, scripts, services, models or whatever).
The solution I built uses Yarn Workspaces, Yarn PnP and Node.js Corepack.
- Node.js 18 (
v18.13.0
) - Yarn
4.0.1
(managed by corepack):$ npm uninstall -g yarn
$ npm install -g corepack
$ corepack enable
- install dependencies (generate
.pnp.cjs
file):
$ yarn
- run compilation process for
shared
package (in watch mode):
$ yarn workspace shared watch # tsc --watch
- run compilation process for
app1
package (in watch mode):
$ yarn workspace app1 watch # tsc --watch
- execute
app1
output:
$ yarn workspace app1 node dist/src/index.js
- production build instruction
- packages versioning