diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-11-24 12:07:36 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-24 17:07:36 +0000 |
commit | b6f49cf4790926df125add2329611a8eff8db9da (patch) | |
tree | 513a81e64185115e50cd06636a410178ed23c14b /cli/node/mod.rs | |
parent | 04afc06b00b28645462f3cca1626d22c1cd579f8 (diff) |
fix(npm/check): prioritize exports over types entry (#16788)
Diffstat (limited to 'cli/node/mod.rs')
-rw-r--r-- | cli/node/mod.rs | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/cli/node/mod.rs b/cli/node/mod.rs index 68eb7b02b..8f0f0ef6d 100644 --- a/cli/node/mod.rs +++ b/cli/node/mod.rs @@ -665,17 +665,7 @@ fn package_config_resolve( let package_config = PackageJson::load(npm_resolver, package_json_path.clone())?; if let Some(exports) = &package_config.exports { - let is_types = conditions == TYPES_CONDITIONS; - if is_types && package_subpath == "." { - if let Ok(Some(path)) = - legacy_main_resolve(&package_config, referrer_kind, conditions) - { - return Ok(Some(path)); - } else { - return Ok(None); - } - } - return package_exports_resolve( + let result = package_exports_resolve( &package_json_path, package_subpath.to_string(), exports, @@ -683,8 +673,23 @@ fn package_config_resolve( referrer_kind, conditions, npm_resolver, - ) - .map(Some); + ); + match result { + Ok(found) => return Ok(Some(found)), + Err(exports_err) => { + let is_types = conditions == TYPES_CONDITIONS; + if is_types && package_subpath == "." { + if let Ok(Some(path)) = + legacy_main_resolve(&package_config, referrer_kind, conditions) + { + return Ok(Some(path)); + } else { + return Ok(None); + } + } + return Err(exports_err); + } + } } if package_subpath == "." { return legacy_main_resolve(&package_config, referrer_kind, conditions); |