-
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
Replace resolved
field by hash
#64
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
- Start Date: 2017-05-09 | ||
- RFC PR: | ||
- Yarn Issue: | ||
|
||
# Summary | ||
|
||
The lockfile yarn.lock should not include the base registry (`https://registry.npmjs.org`). | ||
|
||
# Motivation | ||
|
||
In yarn.lock, the `resolved` field includes registry such as `https://registry.npmjs.org`. | ||
In China, most developers will set it to `https://registry.npm.taobao.org` for speed; but it seems slow for travis-ci and circleci. | ||
|
||
# Detailed design | ||
|
||
Replace the `resolved` by a `hash` field. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think hash would not be enough.
should be converted into
Where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually it would require everyone to update their lockfiles to have the partial tarballs URLs, that may limit the usefulness of this feature.
It would allow people from remote areas seamlessly switch registries for existing projects There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bestander as noted in my motivation comment, retaining the registry URL within in a
I can see that it would require intervention by each project to upgrade their There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you still release your yarn.lock to open source then you want the https://registry.yarnpkg.com domain to be present. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why insn't the hash enough @bestander? Isn't the url completely inferred from repository+name+version? Here the hash would be present to ensure the artefact is the right one only, not for localisation at all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tarball URL is returned by npm backend https://github.com/yarnpkg/yarn/blob/master/src/resolvers/registries/npm-resolver.js#L189, Yarn is not constructing it. I don't think URL reconstruction is justified There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a way, the whole point of this RFC to discuss do that: constructing the URL on the fly :) When you say it is the npm backend constructing the URL, do you mean that IF we wanted to reconstruct it, we would need to store in the lockfile that it is a npm dependency so that we know we need the npm backend to reconstruct the full URL? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True :) I mean that npm is responsible for sending us the URL, for compatibility reasons we probably don't want to move this logic to Yarn. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well you don't need to move it in yarn, you simply need to ask npm again every time :) I understand this is a tricky place to make changes, but personally, I feel like yarn is broken by design by the choice of storing urls directly in the lock file (and I'm curious to see how npm is going to tackle this with their new coming version). The alternative of using a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Okay, so now I see what you mean, and I agree that entirely removing the resolution URL from If the URL must follow a specific spec, could the logic used to generate the value of
Another thought that came to mind is what happens where there are multiple registries that need to be overwritten? I've been assuming a developer only needed to override a single registry, but what if a |
||
The `url` in `resolved` is unnecessary; keeping `hash` is enough. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we get an example of what the |
||
|
||
# How We Teach This | ||
|
||
Just set the registry before `yarn install` if you do not want to use `https://registry.npmjs.org`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reference to the npm registry needs to be replaced with a reference to the Yarn registry - https://registry.yarnpkg.com |
||
Or use `yarn install --registry=https://registry.npm.taobao.org`. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll probably need to emphasize on the documentation website that |
||
# Drawbacks | ||
More effort is needed in order to support users who really need the whole `resolved` field in their project. | ||
|
||
# Alternatives | ||
|
||
Don't change the lockfile, but change the real registry by | ||
|
||
`yarn install --registry=https://registry.npm.taobao.org` | ||
|
||
# Unresolved questions | ||
|
||
No questions | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As an open question, I would like to ask how will this be rolled out to all Yarn using projects? Will Yarn replace the entire |
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.
Could we also add as a motivation that the current approach leads to developers leaking their internal artifact repository sites to the public internet via
yarn.lock
if they have their company's artifact repository configured in a.npmrc
or.yarnrc
file.