Skip to content
Mat Brown edited this page Mar 14, 2019 · 17 revisions

This document collects various tips, conventions, and procedures that may be useful to Popcode contributors. In particular, any code review feedback that draws on a general principle should be accompanied by a section in this document (which will be expanded as demanded by that rule).

Managing dependencies

Avoiding unnecessary duplicate versions

yarn’s dependency resolution algorithm often results in multiple versions of the same package being installed, even when there is one version that satisfies all constraints. The yarn-deduplicate tool is designed to mitigate this by operating on an existing yarn.lock file, merging together duplicate dependencies wherever possible. To run it in Popcode, run this:

$ yarn deduplicate

Popcode’s CI includes a check for duplicate dependencies, and will fail if yarn deduplicate needs to be run.

Avoiding unnecessary version changes in yarn.lock

If your pull request adds, updates, or removes package dependencies, it’s important that the changes to the yarn.lock file reflect the differences in package.json, and nothing more. Particularly in the case of a merge conflict with master, yarn will sometimes inadvertently upgrade unrelated package dependencies when auto-resolving the conflict.

The easiest way to ensure that the changes to yarn.lock are kept to the necessary minimum is to do this:

$ git checkout master -- yarn.lock
$ yarn install
$ yarn deduplicate

If you’re dealing with a merge conflict in the middle of a rebase, do this instead:

$ git checkout HEAD -- yarn.lock
$ yarn install
$ yarn deduplicate
$ git add yarn.lock
$ git rebase --continue
Clone this wiki locally