This repo contains a script that reproduces a case where upgrading a package
with yarn then running yarn install
changes the yarn.lock
.
The script is in test.sh
, and should be easy to follow. I've included a more
detailed explanation of what it's doing below.
- Clone the project
- Run
./test.sh
- Observe the results and inspect the
yarn.lock
files inproject
, andisolated-upgrade
- Create a clean directory (
project/
), and copy in apackage.json
andyarn.lock
that depend on (among other things) react-scripts v0.9.5. - Run
yarn install
in the directory to pull down all the packages, populatingnode_modules
. - Copy the directory in its entirety (including
node_modules
) into a new directory (isolated-upgrade/
). - Inside
isolated-upgrade/
, useyarn add
to upgrade react-scripts to v1.0.6. - Copy the
package.json
andyarn.lock
from theisolated-upgrade/
directory back to theproject/
directory - Inside
project/
, useyarn install
to upgrade react-scripts, as it now has the updated dependency files.
At the end, we have two yarn.lock
files:
isolated-upgrade/yarn.lock
: the result of effectively doing ayarn add react-scripts@1.0.6
in the original projectproject/yarn.lock
: the result of taking an upgradedyarn.lock
, and doing ayarn install
with the original set of packages (equivalent to pulling down an updated lockfile from GitHub)
I'd expect these files to be the same, but - at least when I run this on my machine - they're different.
For simpler sets of dependencies (e.g. just react-scripts) yarn 0.24 produces inconsistent results, but yarn 0.26 produces consistent results (possibly as a result of this PR). However, with the more complex files I've included in this repo, even yarn 0.26 produces inconsistent results.