summaryrefslogtreecommitdiff
path: root/cli/node/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/node/mod.rs')
-rw-r--r--cli/node/mod.rs31
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);