yarn workspaces in CI
Yarn workspaces manage a monorepo of packages from one install.
In CI you often build or test every workspace, or just the ones that changed. Yarn Berry adds the foreach plugin for this.
Common usage
yarn workspaces list- list packagesyarn workspaces foreach -pt run build- parallel topological buildyarn workspace <name> <script>- one package
Example in CI
Build all workspaces in dependency order.
shell
yarn workspaces foreach -pt run buildIn CI
foreach needs the workspace-tools plugin in Berry. For heavy monorepos, faster managed runners cut total build time noticeably.
Key takeaways
foreach -ptbuilds in parallel, topologically.yarn workspace <name>targets one package.- Berry needs the workspace-tools plugin.