Skip to content

Latest commit

 

History

History
91 lines (68 loc) · 3.8 KB

developing.md

File metadata and controls

91 lines (68 loc) · 3.8 KB

Developing

Table of Contents

Installing dependencies

Carbon is built using a collection of packages all built in the same git repository. You might have heard this setup described as a monorepo.

As a result, we use two pieces of tooling to help us managing installing dependencies and publishing our packages. These include:

  • Yarn workspaces for handling dependencies across all packages
  • Lerna for publishing packages, tagging versions, and more

In order for you to install all the dependencies in this project, you'll need to install Yarn and run the following command in your terminal:

yarn install

This will install all of the dependencies for every package in our project. In addition, it allows us to link between packages that we are developing.

This strategy is particularly useful during development, and tooling like Lerna will pick up on when packages are linked in this way and will automatically update versions when publishing new versions of packages.

Next up, you'll most likely want to build all of the package files so that things don't fail while you are working on a package. To do this, you can run the following command:

yarn build

Afterwards, you should be good to go! For more information about how we handle dependencies, definitely take a look at our write-up here.

Common tasks

While working on Carbon, here are some of the top-level tasks that you might want to run:

Command Usage
yarn build Uses lerna to run the build script in each package
yarn clean Resets the state of the project by removing all node_modules and running the clean script in each package
yarn doctoc Runs doctoc on all files in the doctoc directory
yarn format, yarn format:diff Format files using prettier, check if files have been formatted
yarn sync Sync package files across the project

In addition, you can use yarn to run bin files using the yarn <bin> syntax. For example, if you wanted to use lerna to run a script in every package you could do the following:

# Access $(yarn bin)/lerna and pass `run build` to the executable
yarn lerna run build

FAQ

CircleCI is failing saying that it cannot find a dependency in offline mode

Most likely this is due to Yarn mistakenly removing, or forgetting to add, a dependency to our offline mirror. Typically, running the following set of commands should reset the project back to a valid state and should bring back any missing dependencies or fetch new ones.

yarn clean
yarn cache clean
yarn