-
Notifications
You must be signed in to change notification settings - Fork 147
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
Rewrite the registry-url-in-lock-file
RFC
#99
Merged
bestander
merged 2 commits into
yarnpkg:master
from
Gudahtt:update-registry-lockfile-RFC
Sep 15, 2018
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
- Start Date: 2017-09-21 | ||
- RFC PR: | ||
- Yarn Issue: | ||
|
||
# Summary | ||
|
||
Yarn should always use the registry configured by the current user, falling back to the default registry otherwise. It should not use the registry specified in the `resolved` field of lockfile. | ||
|
||
# Motivation | ||
|
||
The default registry used by Yarn is `registry.yarnpkg.com`, but the use of alternate registries is possible through configuration or command-line flags. Using an alternate registry can be useful for a number of reasons; it can improve performance, facilitate serving private packages, and improve the reliability of build and test servers. However, many of these use cases are environment specific. These benefits cannot be realized without allowing the use of different registries in different environments. | ||
|
||
* Using a registry mirror that is closer to you can dramatically improve performance. Using a single registry mirror might work well for teams that work in the same office, but teams that span great distances will need to use different registry mirrors to see the same benefit. | ||
* Build environments can benefit from using a dedicated registry. In addition to the performance benefits, it can also protect against outages that might affect the public registries. | ||
|
||
Currently, Yarn will only use the configured registry for newly installed packages. For packages that are listed in the lockfile already, Yarn will use the registry saved in the lockfile instead, ignoring the registry configuration of the current user. This effectively prevents switching registries between environments. | ||
|
||
# Detailed design | ||
|
||
Yarn should adopt the behavior `npm` introduced with `npm@5`, which is to always use the registry configured by the current user. This change was described in [this blog post](http://blog.npmjs.org/post/161081169345/v500): | ||
>If you generated your package lock against registry A, and you switch to registry B, npm will now try to install the packages from registry B, instead of A. If you want to use different registries for different packages, use scope-specific registries (npm config set @myscope:registry=https://myownregist.ry/packages/). Different registries for different unscoped packages are not supported anymore. | ||
|
||
Yarn already supports switching to a different registry and scoped registries. The change would be to use them in all cases rather than just for new packages. | ||
|
||
### What about the `resolved` field in the lockfile? | ||
|
||
The `resolved` field will not be used to determine which registry is used. Changes to to the `resolved` field, such as removing the registry, are outside the scope of this RFC. | ||
|
||
### How do scoped registries work? | ||
|
||
Yarn supports configuring a registry for a specific scope (e.g. `yarn config set '@foo:registry' 'https://registry.foo.com'`). If a scoped registry has been configured, then this registry shall be used for **all** packages under that scope. Using different registries within a single scope is not supported. | ||
|
||
### Can I configure a specific non-scoped package use an alternate registry? | ||
|
||
No, non-scoped packages would all use the same registry. This restriction simplifies the configuration, and keeps us in line with `npm`. | ||
|
||
### Should the `resolved` field be used as a fallback? | ||
|
||
No, the user's configured registry should be used at all times. Falling back to `resolved` could hide problems (i.e. outdated or misconfigured mirrors) and negatively affect performance. It could also leak information to third parties about which packages are being used, which might be undesirable in certain environments. | ||
|
||
# How We Teach This | ||
|
||
We should improve the documentation for configuring Yarn, with a focus on the registry and scoped registry configuration. This change should also be featured prominently and explained in the release notes, and any blog post or announcement accompanying the version this ships in. This is a significant change, but it does bring it more in line with the behavior of `npm`, which many people are familiar with. | ||
|
||
Overall, the behavior of Yarn should be easier to understand after this change. The behavior will be more transparent and controllable by the user. | ||
|
||
# Drawbacks | ||
|
||
1. This would be a breaking change. | ||
2. Alternate registries for non-scoped packages (or within scopes) would be impossible | ||
While this was never supported officially, it was possible to do by directly editing the `yarn.lock` file. With this change, that would no longer be possible. | ||
|
||
# Alternatives | ||
|
||
1. Add additional configuration for overriding registries | ||
We could preserve the existing behavior, but add additional configuration for overriding the registry. This `override-registry` would behave like `registry` configuration does in the main proposal. This would allow users to opt-in to the new behavior without making a breaking change. | ||
While this would solve the problem, it would also make the configuration more confusing and difficult to teach. | ||
2. Use the `registry` configuration only as a fallback to the `resolved` field | ||
This could allow the install to succeed in cases where the `resolved` field has a registry that is inaccessible to the current user. However it would do nothing to address the use case where an alternate registry is used for performance reasons. | ||
|
||
# Unresolved questions | ||
|
||
* What is the performance impact of not using the cached tarball URL (`resolved`)? |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that much - do you see a drawback removing it from the lockfile? Leaving it there seems confusing, since the lockfile would then contain "useless" data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I elaborated on this in a comment on the other PR.
But even if we do remove it, it had been my intention to submit a separate RFC for that step. They are definitely related, but the proposal in this RFC doesn't depend on changing the lockfile format. Because of that, I thought it might be helpful to separate the two ideas. Also it seemed like @bestander was asking for the original proposal to be split back in 2017, so I thought he might prefer it this way 😛 .
I am open to adding that to this RFC though, if that is preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Gudahtt thank you for driving this work forward.
This RFC will help our organization work around the consequences of hard-coded registry URLs in the lock file.