-
Notifications
You must be signed in to change notification settings - Fork 1
Monorepos
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 inapps/my-custom-api
and then addmy-custom-api
to an app'spackage.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
storesnode_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
...
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.