Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add --prefer-online flag: use cache only if network is not available #2747

Closed
wants to merge 1 commit into from

Conversation

voxsim
Copy link
Contributor

@voxsim voxsim commented Feb 21, 2017

Summary

After reviewing facebook/create-react-app#1235 we should have a --prefer-online flag that should use use cache only if network is not available and IMHO should be default option.

Right now we have:

  1. the default one which it only downloads from the network; we can call it --online
  2. --offline we use network only if dependencies are not available in local cache
  3. --prefer-offline that fallbacks from offline to online if the package is not in the cache

Test plan

Right now I have no idea how to test it; npm-resolver doesn't have tests; and this is an idea, if someone liked it, i will go ahead and maybe I will rewrite everything.

@bestander
Copy link
Member

Yarn does not optimize for being on the most recent version for all subdependencies, on the contrary most of the effort goes towards hitting the network less.

Let's start from the end.
What is your real world test plan?

@voxsim
Copy link
Contributor Author

voxsim commented Feb 23, 2017

@bestander I think when you use yarn to develop something you usually want the last version from network and if you are offline for some reason, it's ok to download from your cache. This is the case when you create a new react app.
On the contrary, when you use yarn for an infrastructure you will prefer to cache everything on your cache storage and use it. What do you think about it?

Btw for both reasons, i will prefer to have --prefer-offline or --prefer-online to have as a default installation behaviour instead of --offline or --online.

@bestander
Copy link
Member

bestander commented Feb 23, 2017

Ok, this may be useful for people who want the bleeding edge dependency chains, especially bigger library contributors.
Would an upgrade work for you in that cse?
Like yarn install --prefer-offline && yarn upgrade.
That is one command more but it would give you the desired behavior without extra complexity that needs tests and support.

@voxsim
Copy link
Contributor Author

voxsim commented Feb 23, 2017

Mmmh yes it could be a good trade-off ;) For now I will close this pull request and thanks @bestander :D

@voxsim voxsim closed this Feb 23, 2017
@bestander
Copy link
Member

Let me know if that does not work, we'll come up with something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants