Navigation Menu

Skip to content

Dependency Management

James Calcaben edited this page Oct 16, 2019 · 3 revisions

NPM Dependency Management in the PWA Studio Project

PWA Studio is a "monorepo" managed using Yarn workspaces. It contains several NPM packages in its packages/ folder, each with a package.json file, and the root directory contains a package.json file which stores mutual dependencies of the child packages.

Running yarn install from the root will install, hoist, and dedupe the dependencies listed in each workspace's package.json file, plus any dependencies listed in the root package.json file.

Workspaces also simplify our package scripts:

Command Effect
yarn workspaces run clean run the clean script within each package
yarn workspace @magento/venia-concept run watch run the watch script within packages/venia-concept

For Testing and Development Dependencies

Many libraries in PWA Studio are used only for testing, linting, or debugging, such as the jest test framework. When writing a test or adding a lint rule, you may need to install additional libraries.

For Peer Dependencies

An NPM "peer dependency" allows the consumer of a package to control the version of a shared dependency more precisely, and is commonly used when making plugins. Both @magento/pwa-buildpack and @magento/upward-js contain plugins for other libraries, so they list those libraries as peerDependencies which must be installed alongside them.