np
np copied to clipboard
yarn workspaces
Description
Support can be added to selectively publish one/some of your subpackges in a Yarn workspace. I imagine it would then seamlessly integrate with tools like Lerna. As of today, I couldn't find a tool to simply publish a single package (together with its inter-package deps) from a workspace
Related to: #141
Without lerna, Yarn Workspaces support would require looking at the top-level yarn.lock – otherwise np
will try to use npm (and probably fail) or if you specify --yarn
it will also fail because there is no lockfile that it can find.
Perhaps a simple solution would be to exec np
from the root directory (with the yarn.lock) but specify a workspace package.json path?
@mshwery I am also trying to get np with yarn workspaces working. I tried to execute np
from the root but it didn't work. What do you mean exactly by specifying a workspace package.json path? Would be great if you could give an example.
I don't think this is something you can achieve with np today.
My suggesting was to add a feature that could detect when yarn workspaces are used (by looking at the root package.json
file's workspaces
key).
You would probably need a way to also specify which workspace to publish. All np checks (like build
, test
and other lifecycle hooks) would likely need to be scoped to the workspace you want to publish.
Hm, I hoped for an easy solution 😄 but anyways thanks for the quick response!
It would be amazing to have equivalents to npm's --workspace
and --workspaces
flags for np
.
I think this is too big of an ask for np. Monorepos already have plenty of their own publishing workflows