From 8c1677ecbcbb474fc6a5ac9b5f73b562677bb829 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 3 Oct 2023 19:05:06 -0400 Subject: refactor(npm): break up `NpmModuleLoader` and move more methods into the managed `CliNpmResolver` (#20777) Part of https://github.com/denoland/deno/issues/18967 --- ext/node/package_json.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'ext') diff --git a/ext/node/package_json.rs b/ext/node/package_json.rs index 0f7cc5bb1..b24bfdef3 100644 --- a/ext/node/package_json.rs +++ b/ext/node/package_json.rs @@ -97,7 +97,13 @@ impl PackageJson { return Ok(PackageJson::empty(path)); } - Self::load_from_string(path, source) + let package_json = Self::load_from_string(path, source)?; + CACHE.with(|cache| { + cache + .borrow_mut() + .insert(package_json.path.clone(), package_json.clone()); + }); + Ok(package_json) } pub fn load_from_string( @@ -199,11 +205,6 @@ impl PackageJson { scripts, }; - CACHE.with(|cache| { - cache - .borrow_mut() - .insert(package_json.path.clone(), package_json.clone()); - }); Ok(package_json) } -- cgit v1.2.3