yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.39k stars 2.72k forks source link

Workspaces and lockfiles #4206

Open arcanis opened 7 years ago

arcanis commented 7 years ago

Two important limitations with workspaces and lockfiles that have been brought by @jeanlauliac:

Not sure these problems are solvable. Just something to keep in mind, and maybe we can come up with some kind of smart solution.

rtsao commented 6 years ago

Are there any known workarounds for this?

arcanis commented 6 years ago

Not yet, open to any idea

rtsao commented 6 years ago

In any case, it seems like the workspace yarn.lock file should be the source of truth.

A possible solution: what if the relevant subset of the workspace yarn.lock was continuously written to the each individual package. These individual package lockfiles would be ignored by yarn if the package is in a workspace, but would work normally if cloned outside of a workspace.

The last piece would be detecting and resolving conflicts between the workspace and individual lockfiles. These conflicts would arise if an individual repo was updated outside of the workspace.

Alternatively, maybe workspaces could be re-implemented using individual lockfiles instead of a top-level yarn.lock.

chambo-e commented 6 years ago

What about a mode ? Kinda like lerna does.

A global mode with the actual behavior, there is one yarn.lock at the workspace top level. And an independent mode where each package has its own yarn.lock and none at the top level. When the install is made on the full monorepo yarn will internally merge every yarn.lock and install deps without writing a lockfile. When the install is made locally, yarn act just like usual without considering the workspace

This is just a thought, no idea if it can be done

jeremiegirault commented 6 years ago

Hi, In the root package of my lerna repo I'm using a postinstall script like this one lerna exec -- "yarn generate-lock-entry > yarn.lock" It seem to work and generate appropriate lockfiles.

tdfairbrother commented 6 years ago

@jeremiegirault I looked at this but generate-lock-entry doesn't seem to work properly https://github.com/yarnpkg/yarn/issues/2340

RDeluxe commented 6 years ago

That's also problematic for CI/CD, docker, etc. I have a docker-compose file at my root, and Dockerfiles in each of my package. Sadly if I want to do things correctly and use the package folder as its build context, I can't access the yarn.lock file and will bump into the first problem quoted before.