is it possible to force yarn workspaces to use remote version of a package?

343 Views Asked by At

In my company, we have this huge monorepo that contains lots of apps that are developed by different teams and some libraries for shared code between the apps which is maintained by infrastructure team.

Without workspaces, it's really hard to maintain the libraries, but the thing is the appA may want to use libA with version 1.3.x, while appB is using "libA": "1.4.x".

The infrastructure team can change the version of libA in appB to workspace: (as the yarn's doc says) to make sure the workspace version is used, and see the changes instantly without having to build the libA. But the teams developing apps don't want to use the new version until it's stable and published.

So with that in mind, is it possible to force yarn workspaces to use the remote version of a package? What about pnpm workspaces?!

1

There are 1 best solutions below

0
On

https://yarnpkg.com/configuration/yarnrc#enableTransparentWorkspaces

yarn config set enableTransparentWorkspaces false

rm -fR node_modules ../../node_modules ../../yarn.lock # be careful

If there is an appC using "workspace^" to reference libA, yarn install may create a ./node_modules in appB/ .

If appC also use the normal "^0.0.1" to reference libA, yarn install will put the fetched libA in ../../node_modules .