@asidatascience/link-local-monorepo
v1.0.3
Published
A utility for linking all monorepo packages in another project
Downloads
464
Keywords
Readme
Link Local Monorepo
A convenience utility for linking pnpm monorepo packages in another project. Uses the file:
protocol.
- Works with
pnpm
workspaces - Requires the monorepo packages to be in the
packages
directory - Currently only supports linking a single monorepo
- Consuming project must use git and have
pnpm-lock.yaml
at the git root
Installing
pnpm install @asidatascience/link-local-monorepo
- Add a
.pnpmfile.cjs
. Example usage:
const ENV_FILE = '.env';
const ENV_PROPERTY = 'MY_MONOREPO_PATH';
const setupLocalLink = require('@asidatascience/link-local-monorepo').init(ENV_FILE, ENV_PROPERTY);
function readPackage(pkg, context) {
setupLocalLink(pkg);
return pkg;
}
module.exports = {
hooks: {
readPackage,
},
};
Usage
- Add an env file matching defined
ENV_FILE
- Set an environment variable equal to the defined
ENV_PROPERTY
with a path to the mono repo pnpm install
- Unset the value and repeat the install before committing changes
(Recommended) Block lock file commits of local packages
Add a git precommit
hook with the following
pnpm fail-if-linking-local