From 44f84bb12eaf460b96a3ecc58ba4475498227b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Thu, 23 Mar 2017 11:46:12 +0000 Subject: [PATCH] =?UTF-8?q?Prevent=20Yarn=20from=20rewriting=20the=20lockf?= =?UTF-8?q?ile=20when=20switching=20between=20online=20=E2=87=84=20offline?= =?UTF-8?q?=20=20(#51)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Create 0000-offline-resolution-field.md * Update 0000-offline-resolution-field.md * Move 0000-offline-resolution-field.md --- text/0000-offline-resolution-field.md | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 text/0000-offline-resolution-field.md diff --git a/text/0000-offline-resolution-field.md b/text/0000-offline-resolution-field.md new file mode 100644 index 0000000..629fd17 --- /dev/null +++ b/text/0000-offline-resolution-field.md @@ -0,0 +1,41 @@ +- Start Date: (fill me in with today's date, YYYY-MM-DD) +- RFC PR: (leave this empty) +- Yarn Issue: (leave this empty) + +# Summary + +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. + +Related issues: https://github.com/yarnpkg/yarn/issues/393 / https://github.com/yarnpkg/yarn/issues/394 + +Tentative implementation: https://github.com/yarnpkg/yarn/pull/2970/ + +# Motivation + +Yarn currently has two different type of values for the lockfile `resolved` fields: + + - When online, they're in the form `${source}/${name}-${version}.tar.gz#${hash}` + + - But when offline, they're instead `${name}-${version}.tar.gz#${hash}` + +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). + +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). + +# Detailed design + +I suggest the following: + + - Adding the `${source}` part to the `resolved` field even when offline + +# Drawbacks + +Nothing should break. More iterations will be required to address the other issues raised in the previous iterations of this document. + +# How We Teach This + +This change is quite transparent, since it's unlikely the users will ever want to update the yarn.lock file manually. + +# Alternatives + + - Instead of adding the package registry to each `resolved` field, we could remove it instead.