Робочий простір
pnpm має вбудовану підтримку монорепозиторіїв (також відомих як репозиторії з декількома пакунками, репозиторії з декількома проєктами або монолітні репозиторії). Ви можете створити робочий простір, щоб обʼєднати кілька проєктів в одному репозиторії.
A workspace must have apnpm-workspace.yaml
file in itsroot. A workspace also may have an.npmrc
in its root.
Якщо ви розглядаєте управління монорепозиторіями, ви також можете розглянутиBit.Bit використовує pnpm під капотом, але автоматизує багато речей, які зараз виконуються вручну в традиційному робочому просторі, керованому pnpm/npm/Yarn. There's an article aboutbit install
that talks about it:Painless Monorepo Dependency Management with Bit.
Протокол робочого простору (workspace:)
Iflink-workspace-packages is set totrue
, pnpm will link packages from the workspace if the available packagesmatch the declared ranges. For instance,foo@1.0.0
is linked intobar
ifbar
has"foo": "^1.0.0"
in its dependencies andfoo@1.0.0
is in the workspace. However, ifbar
has"foo": "2.0.0"
in dependencies andfoo@2.0.0
is not in the workspace,foo@2.0.0
will be installed from the registry. Така поведінка вносить певну невизначеність.
Luckily, pnpm supports theworkspace:
protocol. При використанні цього протоколу pnpm відмовлятиметься виконувати перетворення на будь-що, окрім пакунків локального робочого простору. So, if you set"foo": "workspace:2.0.0"
, this timeinstallation will fail because"foo@2.0.0"
isn't present in the workspace.
This protocol is especially useful when thelink-workspace-packages option isset tofalse
. In that case, pnpm will only link packages from the workspace iftheworkspace:
protocol is used.