DTodt
DTodt

Reputation: 380

Yarn workspace isolation

I'm having some problems with yarn, on empty setups (when I do not have any versions of my libs on npm).

I've a multi-module project as structured bellow:

root                        # Yarn workspace
 * packages
 |  * lib1-ws               # Angular workspace
 |  |  * projects
 |  |  |  * lib1
 |  |  |     * package.json
 |  |  * package.json
 |  |
 |  * lib2-ws               # Angular workspace
 |  |  * projects
 |  |  |  * lib2
 |  |  |     * package.json # peer depends on lib1
 |  |  * package.json       # depends on lib1
 |  |
 |  * lib3-ws               # Angular workspace
 |     * projects
 |     |  * lib3
 |     |     * package.json # peer depends on lib1
 |     * package.json       # depends on lib1
 |
 * package.json

The projects lib2-ws and lib3-ws require lib1 to be build.

I was trying to release (install, build and publish) lib1 so that I can release lib2 and lib3.

But when I run yarn workspace lib1-ws install or yarn install (inside lib1-ws folder), yarn do try to install lib2-ws and lib3-ws as well, breaking the install operation with this error:

error Couldn't find package "lib1@^0.0.1" required by "[email protected]" on the "npm" registry.

Not sure what I'm missing, is there some command that I can run to ignore this workspace-aggregator thing?

Thanks.

Upvotes: 7

Views: 2969

Answers (1)

DTodt
DTodt

Reputation: 380

It seems that I did not searched enough, after post this question, I read another question that give-me an idea.

My workspaces object became like this:

"workspaces": {
  "packages": [
    "packages/*",
    "packages/**/projects/*"
  ]
}

And it works, now I can install without even build or publish.

[UPDATE]

Because some angular build particularities, after install all dependencies, the empty setup must execute some order (because yarn workspace create symlinks for the libs):

  1. build lib1 then publish lib1
  2. yarn workspace lib2-ws add lib1@latest
  3. yarn workspace lib3-ws add lib1@latest
  4. build lib2 then publish lib2
  5. build lib3 then publish lib3

After this steps, my libs are ready on my verdaccio local repository.

Upvotes: 2

Related Questions