pnpm usage example in a monorepo
You can see that the
sum package is specified as a local
dependency in the
math package's package.json.
This is OK, because pnpm will convert the local dependency into a
semver dependency on publish.
Some of the configs are changed in order to make
pnpm work well with
the monorepo. There is an .npmrc file in the root of the
monorepo with three config values. Lets see what each of them are doing.
link-local = true
This is the most important change for a monorepo.
link-local config makes
pnpm symlink local dependencies and convert them to semver
dependencies before publish. More details about this option at: usage in monorepos
store-path = ~/.store
pnpm use a global store. Packages in monorepos usually have a big set of common
dependencies. A common store will keep all the dependencies in one place, giving a huge boost
to the installation time. More details about shared stores here.
save-exact = false
save-exact config in the root of your monorepo is not obligatory but a good thing.
It will guarantee consistency upon how
pnpm publish will convert the local dependencies into semver dependencies.
Will it use exact or not exact versions.