|
| 1 | +- Start Date: 2017-03-14 |
| 2 | +- RFC PR: |
| 3 | +- Yarn Issue: [yarnpkg/yarn#986](https://github.com/yarnpkg/yarn/issues/986) |
| 4 | + |
| 5 | +# Summary |
| 6 | + |
| 7 | +Allow users to bypass the global cache. |
| 8 | + |
| 9 | +# Motivation |
| 10 | + |
| 11 | +For certain situations, it would be preferrable to not use a global cache for |
| 12 | +packages because the cache takes space and the step of copying from the cache |
| 13 | +to `node_modules` can take a significant amount of time. Some examples are: |
| 14 | + |
| 15 | +1. Building a Docker image. Images are isolated, so there's no point in having |
| 16 | +a cache within the image. If anything, it has the negative effect of increasing |
| 17 | +the image size. |
| 18 | + |
| 19 | +2. Running Yarn in a CI context. This is another example of a potentially |
| 20 | +isolated environment where we would just want to put the installed packages |
| 21 | +directly into `node_modules`. While sophisticated CI setups might have |
| 22 | +multiple projects share the same cache, there are certainly setups that don't |
| 23 | +do that. |
| 24 | + |
| 25 | +Overall, the desired effects of bypassing the cache are to increase the speed |
| 26 | +and decrease the disk usage of certain Yarn commands (i.e., install, add, |
| 27 | +upgrade). |
| 28 | + |
| 29 | +# Detailed design |
| 30 | + |
| 31 | +There should be a CLI switch `--no-cache` that tells Yarn to skip doing any work |
| 32 | +with the cache. |
| 33 | + |
| 34 | +Furthermore, there could be an equivalent `.yarnrc` setting of `no-cache` that |
| 35 | +does the same thing when set to `true`. This way, the developer doesn't need to |
| 36 | +remember to use the CLI switch every time. |
| 37 | + |
| 38 | +# How We Teach This |
| 39 | + |
| 40 | +We would update the [documentation](https://yarnpkg.com/en/docs/cli/cache) for |
| 41 | +the `yarn cache` command. |
| 42 | + |
| 43 | +# Drawbacks |
| 44 | + |
| 45 | +Increases the complexity of the implementation of Yarn. |
| 46 | + |
| 47 | +# Alternatives |
| 48 | + |
| 49 | +In the linked issue, there is a suggestion to set the cache folder to some |
| 50 | +in-memory or temporary location, but this solution is hacky and doesn't really |
| 51 | +help with the speed concern because Yarn still has to do the work of copying |
| 52 | +the packages to `node_modules`. |
| 53 | + |
| 54 | +The same reasoning applies to the option of immediately running |
| 55 | +`yarn cache clean`. |
| 56 | + |
| 57 | +# Unresolved questions |
0 commit comments