MonoRepo (vs ManyRepos) in the Javascript context
When starting with monorepo, integrate first the leaf projects of the dependency graph (ie project without dependency).
To use the library locally without publishing to a remote npm registry.
With the help of symlink, you create a symlink in the parent project to node_modules/dependency that links to the local path of the project dependency.
yarn 1) and npm have a link command
Example of steps with one application and one package dependency.
# go to your package
cd ../my-package
yarn install
yarn link # Create a link from the dependency
# go to your app or package that depends on the first package
cd ../my-app
yarn link my-package
yarn run build
~/my-package$ npm install
~/my-package$ npm link
~/my-package$ cd myApp
~/my-app$ npm link /path/to/my-package
NODE_PATH may be used to emulate a monorepo
NODE_PATH=src
Package manager have automated the link concept and made it easier to create them via the concept of workspace.
They are automating the link operation.
A workspace 2) is a local package managed by a workspace root.
It's actually a yarn concept that create link between Workspaces that depend on each other. The local dependency workspace-a is aliased as /node_modules/workspace-a via a symlink.
Yarn Workspaces permits to dedupe node_modules.
For cli that doesn't relate all path from the working directory, you can use a nohoist
See
Under a child workspace:
"workspaces": {
"nohoist": ["react-native", "react-native/**"],
"packages/*",
"website",
"examples/*"
}
The below tools are versioning packages utility.
They are only needed if you publish them to a registry such as NPM for external consumption.
MonoRepo Manager - Lerna helps to publish package and create changelogs.
It uses also Yarn workspace to get the link
https://github.com/changesets/changesets/
https://github.com/microsoft/beachball - the sunniest version bumping tool
Monorepo framework are bundler that are specialized for a monorepo.
https://github.com/boltpkg/bolt