Building & testing
Installing dependencies
Section titled “Installing dependencies”| Software | How to install |
|---|---|
| Yarn | https://yarnpkg.com/getting-started/install |
| Rust / Rustup | https://rust-lang.org/tools/install |
Building Yarn
Section titled “Building Yarn”Clone the ZPM repository and cd into it:
git clone https://github.com/yarnpkg/zpm.gitcd zpmYou should now be able to build the project:
cargo build --release -p zpm-switch -p zpmWe tend to build Yarn in release mode, even in development, because Rust is known to be significantly slower in debug mode. Regardless of whether you want to use the release or debug version, create a symbolic link named local pointing to the binary you just created:
ln -s target/release localAlso configure your system’s Yarn Switch to use this local version when working on the project:
yarn switch link target/release/yarn-binTesting Yarn
Section titled “Testing Yarn”One of the reasons why the migration from the Classic codebase to the Berry one was so painful was that we lost all our testing framework. All Classic tests were written using internal primitives, so they couldn’t be reused after the redesign.
We learned from that mistake, and the Berry tests were written using the regular CLI as interface. This means it’s easy to swap the binary from Berry to ZPM and run the full Yarn testsuite!
Start by cloning the Berry repository:
git clone https://github.com/yarnpkg/berry.git ~/berryExport a BERRY_DIR environment variable pointing to the Berry repository:
export BERRY_DIR=~/berryThen run the yarn berry command from the ZPM repository:
yarn berry test:integration commands/add.test