yarn.BUILD


BUILD and BUNDLE your local workspaces.
It's like Bazel, Buck and Pants but for Yarn.



How it works.


Install

Run this command in your Yarn project
to install (or upgrade to) versions.

Yarn 4

Or install just the commands you want:


Yarn 2

What is this?

yarn.BUILD is a plugin for Yarn v2 and v3 (berry).


“This is by far my favourite way to build Javascript and Typescript applications.”
Owen Kelly,
Creator yarn.BUILD

How it works

yarn.BUILD doesn't build anything itself. It keeps track of what has been built, and what order packages need to be built in.

When you run yarn build in the directory of a package, it will call the build script in package.json.

If you run yarn build from any other directory in your yarn workspaces, your whole project will be built.

Or run yarn build path/to/package to build just that package (or packages in that folder), and their dependencies.

Because of this, it's easy to integrate into your existing yarn workspaces. And to build packages in languages other than Javascript.

At any time you can add --ignore-cache to force a re-run.


Build

Build a single package (and its dependencies) or all packages in your project.

Run yarn build


Bundle

Create a zip file of your package, bundled up ready to be deployed.

Run yarn bundle in the directory of the package you want to bundle

Everything not required (as described in package.json#dependencies) is removed, and bundled node modules are trimmed to just what's required.

A new file is added to the root directory entrypoint.js. Running this file will automatically link up Yarn PnP and point to your main file in the package that was bundled.

This has been specifically designed to allow easy bundling of packages for AWS Lambda, but works equally well with Kubernetes and Docker and other deployment systems where you can run node.


Test

Test your packages and their dependencies.

Run yarn test in the directory of the package you want to test or run yarn test path/to/package.