You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This feature is important to have in this repository; a contrib plugin wouldn't do
Describe the user story
As a developer maintaining a CI pipeline, I want to keep a dependency cache that invalidates only when yarn.lock changes. However, yarn install requires all workspace package.json files in addition to yarn.lock, which means that the cache invalidates more often than it needs to.
It should be possible to populate the cache using only yarn.lock and no package.json files. The documentation for the pnpm fetch command describes exactly my use case and is similar to the solution I'm proposing.
Describe the solution you'd like
I imagine a yarn fetch command. It would perform a version of dependency resolution using onlyyarn.lock and populate the cache. Later, dependencies could be linked with yarn install --immutable --immutable-cache.
The command could be an external plugin, but currently it's difficult to implement (though possible). Ideally the command would consist mainly of calling Project.resolveEverything, followed by Project.fetchEverything, but currently there are two challenges:
resolveEverything requires reading all workspace package.json files. There's no way to avoid this except to reimplement the necessary pieces within the plugin, duplicating logic.
fetchEverything depends on resolveEverything, but mostly works otherwise. WorkspaceFetcher relies on package.json information, but it's not too hard to provide a custom Fetcher implementation to work around this.
There may be other problems; I've only tried writing a plugin that works for my monorepo use case.
Describe the drawbacks of your solution
A little bit of added complexity and increased surface area for the core API.
Describe alternatives you've considered
I've written a plugin that works for my use case, but it has to reimplement various parts of resolveEverything itself in order for fetchEverything to work properly. It feels fragile and unnecessarily complicated. It's hard for me to be sure that I've implemented it correctly since I'm not very familiar with Yarn internals.
The text was updated successfully, but these errors were encountered:
I created a small package that recreates the full workspace structure with dummy package.jsons just from the yarn.lock file. You can use it in Dockerfile to do a yarn install - /~https://github.com/rohit-gohri/yarn-lock-to-package-json
Use like this
COPY .yarn ./.yarn
COPY yarn.lock .yarnrc.yml ./
RUN yarn dlx yarn-lock-to-package-json
RUN yarn install --immutable
This way you don't need to create a special command since yarn install itself works
Describe the user story
As a developer maintaining a CI pipeline, I want to keep a dependency cache that invalidates only when
yarn.lock
changes. However,yarn install
requires all workspacepackage.json
files in addition toyarn.lock
, which means that the cache invalidates more often than it needs to.It should be possible to populate the cache using only
yarn.lock
and nopackage.json
files. The documentation for thepnpm fetch
command describes exactly my use case and is similar to the solution I'm proposing.Describe the solution you'd like
I imagine a
yarn fetch
command. It would perform a version of dependency resolution using onlyyarn.lock
and populate the cache. Later, dependencies could be linked withyarn install --immutable --immutable-cache
.The command could be an external plugin, but currently it's difficult to implement (though possible). Ideally the command would consist mainly of calling
Project.resolveEverything
, followed byProject.fetchEverything
, but currently there are two challenges:resolveEverything
requires reading all workspacepackage.json
files. There's no way to avoid this except to reimplement the necessary pieces within the plugin, duplicating logic.fetchEverything
depends onresolveEverything
, but mostly works otherwise.WorkspaceFetcher
relies onpackage.json
information, but it's not too hard to provide a customFetcher
implementation to work around this.There may be other problems; I've only tried writing a plugin that works for my monorepo use case.
Describe the drawbacks of your solution
A little bit of added complexity and increased surface area for the core API.
Describe alternatives you've considered
I've written a plugin that works for my use case, but it has to reimplement various parts of
resolveEverything
itself in order forfetchEverything
to work properly. It feels fragile and unnecessarily complicated. It's hard for me to be sure that I've implemented it correctly since I'm not very familiar with Yarn internals.The text was updated successfully, but these errors were encountered: