Skip to content

Commit 13a3102

Browse files
committed
bug fixes
1 parent cff904b commit 13a3102

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/module_wrap.cc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,17 +585,22 @@ Maybe<const PackageConfig*> GetPackageConfig(Environment* env,
585585
IsESM::Bool esm = IsESM::No;
586586

587587
Local<Value> exports_v;
588-
Persistent<Value> exports;
589588
if (pkg_json->Get(env->context(),
590589
env->exports_string()).ToLocal(&exports_v) &&
591590
(exports_v->IsObject() || exports_v->IsString())) {
592591
esm = IsESM::Yes;
592+
Persistent<Value> exports;
593593
exports.Reset(env->isolate(), exports_v);
594+
595+
auto entry = env->package_json_cache.emplace(path,
596+
PackageConfig { Exists::Yes, IsValid::Yes, has_main, main_std,
597+
exports, esm });
598+
return Just(&entry.first->second);
594599
}
595600

596601
auto entry = env->package_json_cache.emplace(path,
597602
PackageConfig { Exists::Yes, IsValid::Yes, has_main, main_std,
598-
exports, esm });
603+
Persistent<Value>(), esm });
599604
return Just(&entry.first->second);
600605
}
601606

@@ -617,7 +622,7 @@ Maybe<const PackageConfig*> GetPackageBoundaryConfig(Environment* env,
617622
if (pjson_url.path() == last_pjson_url.path()) {
618623
auto entry = env->package_json_cache.emplace(pjson_url.ToFilePath(),
619624
PackageConfig { Exists::No, IsValid::Yes, HasMain::No, "",
620-
Persistent<Value>(), IsESM::Yes });
625+
Persistent<Value>(), IsESM::No });
621626
return Just(&entry.first->second);
622627
}
623628
}
@@ -696,7 +701,7 @@ Maybe<ModuleResolution> FinalizeResolution(Environment* env,
696701
if (pcfg.IsNothing()) return Nothing<ModuleResolution>();
697702

698703
if (pcfg.FromJust()->exists == Exists::No) {
699-
return Just(ModuleResolution { resolved, is_main });
704+
return Just(ModuleResolution { resolved, true });
700705
}
701706

702707
return Just(ModuleResolution {
@@ -856,7 +861,7 @@ Maybe<ModuleResolution> PackageResolve(Environment* env,
856861
}
857862
CHECK(false);
858863
// Cross-platform root check.
859-
} while (pjson_url.path().length() == last_path.length());
864+
} while (pjson_url.path().length() != last_path.length());
860865

861866
std::string msg = "Cannot find package '" + pkg_name +
862867
"' imported from " + base.ToFilePath();

0 commit comments

Comments
 (0)