summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuy Bedford <guybedford@gmail.com>2018-02-14 22:55:49 +0200
committerRuben Bridgewater <ruben@bridgewater.de>2018-02-16 19:46:28 +0100
commit7748865cd3322ff9421458ccc862291eb26cec62 (patch)
tree3a8383e729edd92f035eaa2e53e997bce701d761 /src
parent61e3e6d56feefcd88f2baeb59c31c327835a8d90 (diff)
downloadandroid-node-v8-7748865cd3322ff9421458ccc862291eb26cec62.tar.gz
android-node-v8-7748865cd3322ff9421458ccc862291eb26cec62.tar.bz2
android-node-v8-7748865cd3322ff9421458ccc862291eb26cec62.zip
module: fix main lookup regression from #18728
PR-URL: https://github.com/nodejs/node/pull/18788 Refs: https://github.com/nodejs/node/pull/18728 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/module_wrap.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/module_wrap.cc b/src/module_wrap.cc
index 3d34da570a..71f0bbe074 100644
--- a/src/module_wrap.cc
+++ b/src/module_wrap.cc
@@ -544,7 +544,7 @@ const PackageConfig& GetPackageConfig(Environment* env,
}
auto entry = env->package_json_cache.emplace(path,
- PackageConfig { Exists::Yes, IsValid::Yes, has_main, "" });
+ PackageConfig { Exists::Yes, IsValid::Yes, has_main, main_std });
return entry.first->second;
}
@@ -585,13 +585,15 @@ Maybe<URL> ResolveMain(Environment* env, const URL& search) {
GetPackageConfig(env, pkg.ToFilePath());
// Note invalid package.json should throw in resolver
// currently we silently ignore which is incorrect
- if (!pjson.exists || !pjson.is_valid || !pjson.has_main) {
+ if (pjson.exists == Exists::No ||
+ pjson.is_valid == IsValid::No ||
+ pjson.has_main == HasMain::No) {
return Nothing<URL>();
}
if (!ShouldBeTreatedAsRelativeOrAbsolutePath(pjson.main)) {
- return Resolve(env, "./" + pjson.main, search);
+ return Resolve(env, "./" + pjson.main, search, IgnoreMain);
}
- return Resolve(env, pjson.main, search);
+ return Resolve(env, pjson.main, search, IgnoreMain);
}
Maybe<URL> ResolveModule(Environment* env,
@@ -602,7 +604,7 @@ Maybe<URL> ResolveModule(Environment* env,
do {
dir = parent;
Maybe<URL> check =
- Resolve(env, "./node_modules/" + specifier, dir, IgnoreMain);
+ Resolve(env, "./node_modules/" + specifier, dir, CheckMain);
if (!check.IsNothing()) {
const size_t limit = specifier.find('/');
const size_t spec_len =