Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Monorepos

Michael Nutt edited this page Nov 15, 2018 · 1 revision

Oftentimes, you may have multiple projects that are thematically related: either multiple projects for the same company, or multiple projects of the same type, etc. It is usually easier to put them all in a single repository rather than giving each its own repository. This pattern is called 'monorepo'.

Some benefits of monorepos:

  • You can place other libraries you've written within the monorepo. For instance, if all of your monorepo's apps use a my-custom-api module, you could place it in apps/my-custom-api and then add my-custom-api to an app's package.json. yarn install would locate the library within the monorepo and prefer that.
  • git pull fetches changes for all apps in the repository at once
  • yarn stores node_modules dependencies at the top level, so there are fewer redundant modules

The MDK works best with Yarn Workspaces. Read more about how to set up a Yarn Workspace.

$ yarn config set workspaces-experimental true
yarn config v1.10.1
success Set "workspaces-experimental" to "true".
✨  Done in 0.04s.

$ mkdir some-apps
$ cd some-apps
$ git init
Initialized empty Git repository in some-apps/.git/
$ echo node_modules >> .gitignore

Edit some-apps/package.json to look like this:

{
  "private": true,
  "name": "some-apps",
  "workspaces": [
    "apps/*"
  ]
}

Note that while Yarn will let you name your workspace directory anything, the MDK requires you to use the apps directory.

Now make the workspace directory and create an app:

$ mkdir apps
$ cd apps
$ movable new my-app
...

Deployment

Each app within a monorepo deploys separately. For instance: cd apps/my-app; movable deploy production would deploy my-app. This way you can test out changes to a single app rather than having to deploy them all at once.

Clone this wiki locally