Javascript - MonoRepo

> (World Wide) Web - (W3|WWW) > Javascript (Js|ECMAScript) > Shipping/Building Pipeline

1 - About

MonoRepo (vs ManyRepos) in the Javascript context

When starting with monorepo, integrate first the leaf projects of the dependency graph (ie project without dependency).

Advertising

3 - Implementation

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 or rpn have a link command ( yarn link)

Example of steps with one application and one package dependency.

  • Yarn
~ $ cd ../my-package
~/my-package$ yarn install
~/my-package$ yarn run build 
~/my-package$ yarn link # Create a link from the dependency
~/my-package$ cd ../my-app
~/my-app$ yarn link my-package
~/my-app$ yarn run build
  • Npm
~/my-package$ npm install
~/my-package$ npm link
~/my-package$ cd myApp
~/my-app$ npm link /path/to/my-package

3.2 - Workspace

A workspace is a local package managed by a workspace root.

It's actually a yarn concept that create symlinks between Workspaces that depend on each other. The local dependency workspace-a is aliased as /node_modules/workspace-a via a symlink.

For cli that doesn't relate all path from the working directory, you can use a nohoist See

Under a child workspace:

package.json
<code
"workspaces": {
  "nohoist": ["react-native", "react-native/**"]
}
Advertising

3.3 - Env

NODE_PATH may be used to emulate a monorepo

NODE_PATH=src

3.4 - Utility

4 - Doc

web/javascript/shipping/monorepo.txt · Last modified: 2019/06/19 14:56 by gerardnico