[Feature] Why can't we have a global .cache/{package}/{version} all projects use for speed(download once not once per project) #4394
deanhiller
started this conversation in
General
Replies: 2 comments 3 replies
-
That's already the case, we have a global cache https://yarnpkg.com/features/offline-cache. |
Beta Was this translation helpful? Give feedback.
2 replies
-
I'm also curious why the front end manages packages this way, and why not use global management packages like nuget, instead of downloading them over and over again? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the user story
"As a developer, every time I open a project using package react version 4.2.1, I want it to not RE-download it again and again for each project as that is annoying and costs time"
Describe the solution you'd like
Something like gradle/maven/ivy from java uses this structure
.cache/{packageName}/{version}
In this way, if projects use different versions, they reference different locations in the global .cache directory which is stored in my home directory outside all projects.
Describe the drawbacks of your solution
Drawbacks are ^4.2.1 keeps installing new stuff though doing ^4.2.1 has been known not to scale at large organizations like Twitter where that guarantees at least one team is accidentally upgrading all the time to a release with a bug thereby breaking production(usually auto upgrades were found at scale not to be a good idea and work only for small teams but even if you ask 100 startsups, there is 99% chance one hit an issue with that method)
For monorepos, there is also the diamond problem. Microservice A depends on library B and library C. library C depends on 3rd party library D version 1.2.1 while library C depends on library D version 1.2.2. Java/scala had this issue at Twitter when I was there so it was solved with a locked versions file for all projects so everyone pulled in the same version (for monorepos only though....basically in typescript world, package.json would have a relative reference to a global file that held a fixed version for library D for all projects). At Twitter, you could go outside use version 1.2.1 library D but most would use the global as it avoided the diamond problem.
Another advantage of having all fixed versions instead of ^1.2.1 was that running yarn start could depend on yarn install and result in no remote calls. Developers simply 'git pull' and run 'yarn start' (yarn install was run for you which is lightning quick if nothing is needed where if you have ^1.2.1, you have to check remotely - java originally tried that method with ivy but quickly it became a nightmare of bugs and build time issues). If there are changes, yarn start would auto install new deps which does not happen today so I see developers accidentally running yarn start but then forgetting to updated 3rd party libs so they are out of date as they run their server.
Describe alternatives you've considered
I am new to typescript and wonder where many of the enterprise features are but excited to see the community catch up as gradle was the most amazing build system on the market regarding change detection for speed and scale.
(Sorry, I probably lived in gradle way too long but I keep seeing developers say 'well, it works for me' which we didn't have as much in gradle world where everyone ran the exact same versions)
Beta Was this translation helpful? Give feedback.
All reactions