![]() ![]() By default Yarn will use the refs specified by the changesetBaseRefs configuration option.” ”If -since is set, Yarn will only run the command on workspaces that have been modified since the specified ref. Indeed it does, and surprisingly (or not) it has the same name: “ since”. I’m pretty sure NX has the same, but I’m not interested in it since, as mentioned before, my workspace manager is Yarn. (This will tell Lerna to run the test command only on packages which changed compared to the main branch). Paying this time for a mere change to a component is what they call a “bad dev velocity”.įor those of you who are using Lerna there is this nice filter option parameter to the lerna run command called “ since”, so the command could look something like this: To put in simple words, introducing a change to the “components” package will now run the entire linters for all the packages, tests for all the packages and then build all the packages. Running these scripts for the entire packages is nice and dandy for a small Monorepo, but when you’re dealing with a big one, which has, let’s say, many components on its “components” package that each has a test to it or has a lot of packages that each is instructed to be built, the pipeline become v.e….r……y slow. Lint, Build and Test are commands which execute across the entire package, and here is where it may present a problem… Here is my root package.json file:Įnter fullscreen mode Exit fullscreen mode In my Pedalboard Monorepo there are several commands which get executed across all packages. This is the reason I will be focusing on Yarn in this post. ![]() In another post I wrote, titled “ Rethinking the “One Ring To Rule Them all” Monorepo manager”, I dealt with the issue of Monorepo’s tools and stated that I find it better for each tool to be responsible for its domain, avoiding the “all in one” approach.īecause of that reason, the tool I selected to manage my workspaces is Yarn, so Yarn is basically responsible for running commands across all packages. Lerna has the lerna run command, NX has the nx run-many and Yarn has the yarn workspaces foreach. If we take the 3 main tools out there to help us manage such a thing we will see that they all support executing commands across all packages. Luckily for us we don’t need to invent anything in order to incorporate this behavior into our Monorepo. Another example is the build command which instructs to build every package the Monorepo has. Obviously each package should have the command instructions for the test command in its package.json, but you would like to have the means to trigger the test command for all the packages under the Monorepo in one call. When you manage multiple packages on the same repo you need to have some tools to execute scripts across all the packages for good DX and for solid pipelines.įor instance, let’s take the “test” command. I would suggest adding 1 command in each workspace with the same name which unlinks and links the required local dependencies then calling them all with one foreach command.Īfter re-reading your inital question I realise you're using Yarn Workspaces which means you don't even need to use Yarn Link at all to have one local package be a dependency in another package.įrom the directory of the package which requires the local package run: yarn add is the name of the required package.In this week’s post join me as I stop my Monorepo from being greedy and instruct it to lint, test and build only what’s required using Yarn workspaces and some black magic spells.Ī Monorepo allows you to manage multiple packages on a single repo. Unlink: yarn workspaces foreach run unlink To add the plugin run: yarn plugin import workspace-tools ![]() Using the Yarn workspace-tools plugin you can make use of the Yarn foreach command to run a command on all workspaces.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |