Skip to content

Commit 44f84bb

Browse files
arcanisbestander
authored andcommitted
Prevent Yarn from rewriting the lockfile when switching between online ⇄ offline (#51)
* Create 0000-offline-resolution-field.md * Update 0000-offline-resolution-field.md * Move 0000-offline-resolution-field.md
1 parent 9bfe478 commit 44f84bb

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

text/0000-offline-resolution-field.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
- Start Date: (fill me in with today's date, YYYY-MM-DD)
2+
- RFC PR: (leave this empty)
3+
- Yarn Issue: (leave this empty)
4+
5+
# Summary
6+
7+
When enabling the offline mirror, Yarn updates the lockfile by stripping the registry URL from its `resolved` fields. This RFC aims to simplify this process by making such an update unneeded.
8+
9+
Related issues: https://github.com/yarnpkg/yarn/issues/393 / https://github.com/yarnpkg/yarn/issues/394
10+
11+
Tentative implementation: https://github.com/yarnpkg/yarn/pull/2970/
12+
13+
# Motivation
14+
15+
Yarn currently has two different type of values for the lockfile `resolved` fields:
16+
17+
- When online, they're in the form `${source}/${name}-${version}.tar.gz#${hash}`
18+
19+
- But when offline, they're instead `${name}-${version}.tar.gz#${hash}`
20+
21+
The current reasoning (or at least side effect) seems to be that it allows the fetch process to refuse installing things from the network when running under the `--offline` switch (and to always fetch things from the network otherwise instead of looking into the offline mirror). Unfortunately, such a separation also makes it harder to switch between working with a remote registry and an offline repository (for example, dev environments might not need the offline repository, but under the current design they can't do without).
22+
23+
Because of these reasons, it would be best for the `resolved` field to contain the same informations during both online and offline work, *as long as the files we fetch are the expected ones* (ie. their hashes match).
24+
25+
# Detailed design
26+
27+
I suggest the following:
28+
29+
- Adding the `${source}` part to the `resolved` field even when offline
30+
31+
# Drawbacks
32+
33+
Nothing should break. More iterations will be required to address the other issues raised in the previous iterations of this document.
34+
35+
# How We Teach This
36+
37+
This change is quite transparent, since it's unlikely the users will ever want to update the yarn.lock file manually.
38+
39+
# Alternatives
40+
41+
- Instead of adding the package registry to each `resolved` field, we could remove it instead.

0 commit comments

Comments
 (0)