And so if you're ever interested in the work we're doing there you can go to npm slash benchmarks and you can go see the different runs that we're doing against the different versions of npm that we're building.
So npm v7 introduced support for workspaces. This was a huge win for our team. It's something that we wanted to offer to the developer community for a while now. And the basic support here for workspaces is just the definition of the projects within your root project.
So in this case, in this example, I've just defined essentially an A and a B workspace. And as of v7, 7.0.0, the only real command that understood or supported these workspace definitions was npm install. And I actually have a reference there to our docs. And there's references also back to the RFC that we originally created for this basic support.
So since then, we sort of broke out the work into another two phases. And the second of which is what we've been working on just recently, which is making more commands essentially workspace aware. And this second stage of this work, really encompasses all the other 60 plus commands that we have to define them and categorize them in terms of their workspace awareness.
So what you'll see is two new configurations that are actually going to be released in the next week or so, along with some other work that is associated with workspace awareness. So the first config that we have is workspaces. And it's essentially a bullion to be passed to any of the NPM commands to let you know that you'd like to run that command against the workspaces that you've defined. And then the second config is sort of a filtered command for the specific workspace you'd like to run the command against. So that's just workspaces and workspace. So ws and w are the aliases.
And if we see what this looks like in practice, so as of NPM 7.7, you will be able to run on any of the lifecycle scripts or lifecycle commands like run scripts, run test, start, stop, restart with the ws or w flags. In this case, I've run test with ws, and it goes and runs all the test scripts that are in the workspaces that I've defined in my project. And here, in this case, in this example, I've actually filtered just to run the test for the workspace A that I've defined in this project.
And workspace is pretty nice because it's very composable. You can actually define workspace many times. So, in this case, in this case, I've actually defined B and then A. And because of the way that this is implemented, they run serially. And you can see that B's tests run first and then A's. And if I were to define more and more workspaces, you'd essentially see more and more runs done.
So, this new feature, this new capability with working with workspaces is available as of NPM v7.7, which we're releasing in the next few days. 7.8 will have exec and init support and the rest of the subcommands becoming workspace-aware will come subsequently after that. If you're ever looking to get the latest version of NPM, you can install us with npmi npm-g.
Comments