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
fix: don't write pnpm-lock.yaml
if it has no changes
#6260
Conversation
pnpm-lock.yaml
if it has no changes
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.
Thanks!
pkg-manager/headless/src/index.ts
Outdated
@@ -545,7 +546,7 @@ export async function headlessInstall (opts: HeadlessOptions) { | |||
storeDir: opts.storeDir, | |||
virtualStoreDir, | |||
}) | |||
if (opts.useLockfile) { | |||
if (opts.useLockfile && JSON.stringify(wantedLockfile) !== JSON.stringify(opts.wantedLockfileUnmodified)) { |
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.
nit: It might be worth following up with a deepEqual(...)
function that early exits as soon as it sees the lockfiles are different for performance. I've seen pnpm-lock.yaml
files grow to be 4MB, and serializing 2 * 4MB could add a few seconds to each pnpm install
.
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 have changed it. There was actually no need in the copy.
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.
Nice!
@@ -128,6 +129,7 @@ export async function readLockfiles ( | |||
existsCurrentLockfile: files[1] != null, | |||
existsWantedLockfile: files[0] != null && !isEmptyLockfile(wantedLockfile), | |||
wantedLockfile, | |||
wantedLockfileUnmodified: JSON.parse(JSON.stringify(wantedLockfile)), |
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.
nit: It might be worth a comment that we have to recreate this object since the consumer is expected to mutate wantedLockfile
. But maybe that's fairly obvious and isn't worth commenting.
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 was also considering just to save the hash of the object and then comparing hashes. That would use less memory but probably would do more processing
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 have changed it. There was actually no need in the copy.
close #6158