From 5149d07335791662c0da3a61112ce82f4bd418ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 27 Feb 2023 21:02:19 +0100 Subject: [PATCH] fix(lockfile): don't touch lockfile is npm specifiers are identical (#17973) We were unconditionally inserting npm specifiers into the lockfile, marking it as "dirty" and requiring saving. --- lockfile/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lockfile/lib.rs b/lockfile/lib.rs index b8caac86c2..616a8da981 100644 --- a/lockfile/lib.rs +++ b/lockfile/lib.rs @@ -297,12 +297,17 @@ Use \"--lock-write\" flag to regenerate the lockfile at \"{}\".", serialized_package_req: String, serialized_package_id: String, ) { + let maybe_prev = self.content.npm.specifiers.get(&serialized_package_req); + + if maybe_prev.is_none() || maybe_prev != Some(&serialized_package_id) { + self.has_content_changed = true; + } + self .content .npm .specifiers .insert(serialized_package_req, serialized_package_id); - self.has_content_changed = true; } }