diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-11-07 09:56:06 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-07 09:56:06 -0500 |
commit | 9201198efd6fb116585d4c26111669f4c1006e5d (patch) | |
tree | 746b2283da7edb457cea5eced2bc6cd7b42b8067 /ext/node/package_json.rs | |
parent | 50e4806a2db66be289aa123a0bfd8dd8688712ba (diff) |
fix(node): inspect ancestor directories when resolving cjs re-exports during analysis (#21104)
If a CJS re-export can't be resolved, it will check the ancestor
directories, which is more similar to what `require` does at runtime.
Diffstat (limited to 'ext/node/package_json.rs')
-rw-r--r-- | ext/node/package_json.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/node/package_json.rs b/ext/node/package_json.rs index 104c87390..035d26ed8 100644 --- a/ext/node/package_json.rs +++ b/ext/node/package_json.rs @@ -110,8 +110,13 @@ impl PackageJson { path: PathBuf, source: String, ) -> Result<PackageJson, AnyError> { - let package_json: Value = serde_json::from_str(&source) - .map_err(|err| anyhow::anyhow!("malformed package.json {}", err))?; + let package_json: Value = serde_json::from_str(&source).map_err(|err| { + anyhow::anyhow!( + "malformed package.json: {}\n at {}", + err, + path.display() + ) + })?; Self::load_from_value(path, package_json) } |