Skip to content
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

Merged
merged 2 commits into from Mar 23, 2023
Merged

fix: don't write pnpm-lock.yaml if it has no changes #6260

merged 2 commits into from Mar 23, 2023

Conversation

zkochan
Copy link
Member

@zkochan zkochan commented Mar 23, 2023

close #6158

@zkochan zkochan requested a review from a team March 23, 2023 01:36
@kenrick95 kenrick95 changed the title fix: don't writ pnpm-lock.yaml if it has no changes fix: don't write pnpm-lock.yaml if it has no changes Mar 23, 2023
@zkochan zkochan changed the title fix: don't write pnpm-lock.yaml if it has no changes fix: don't write pnpm-lock.yaml if it has no changes Mar 23, 2023
Copy link
Member

@gluxon gluxon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@@ -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)) {
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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)),
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member Author

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.

@zkochan zkochan merged commit 2a20328 into main Mar 23, 2023
14 checks passed
@zkochan zkochan deleted the fix/6158 branch March 23, 2023 02:40
zkochan added a commit that referenced this pull request Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants