diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-12-15 21:15:25 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-15 21:15:25 -0500 |
commit | 9e977cd6aaabc6618421578654becafa1ab611f5 (patch) | |
tree | 5f5c5fc2799ec46e77d758516e6ad1fb349764ab /ext/node/errors.rs | |
parent | 28cc18b5168d926577795eaf3974095da2def3e8 (diff) |
fix(npm): improve exports resolution when type checking (#17071)
Closes #17012
Diffstat (limited to 'ext/node/errors.rs')
-rw-r--r-- | ext/node/errors.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/ext/node/errors.rs b/ext/node/errors.rs index 929f51e1b..b489cb937 100644 --- a/ext/node/errors.rs +++ b/ext/node/errors.rs @@ -1,5 +1,7 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +use std::path::PathBuf; + use deno_core::error::generic_error; use deno_core::error::type_error; use deno_core::error::AnyError; @@ -61,13 +63,26 @@ pub fn err_invalid_package_target( ) -> AnyError { let rel_error = !is_import && !target.is_empty() && !target.starts_with("./"); let mut msg = "[ERR_INVALID_PACKAGE_TARGET]".to_string(); + let pkg_json_path = PathBuf::from(pkg_path).join("package.json"); if key == "." { assert!(!is_import); - msg = format!("{} Invalid \"exports\" main target {} defined in the package config {}package.json", msg, target, pkg_path) + msg = format!( + "{} Invalid \"exports\" main target {} defined in the package config {}", + msg, + target, + pkg_json_path.display() + ) } else { let ie = if is_import { "imports" } else { "exports" }; - msg = format!("{} Invalid \"{}\" target {} defined for '{}' in the package config {}package.json", msg, ie, target, key, pkg_path) + msg = format!( + "{} Invalid \"{}\" target {} defined for '{}' in the package config {}", + msg, + ie, + target, + key, + pkg_json_path.display() + ) }; if let Some(base) = maybe_referrer { |