module: named exports for CJS via static analysis

PR-URL: https://github.com/nodejs/node/pull/35249
Reviewed-By: Mary Marchini <oss@mmarchini.me>
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
This commit is contained in:
Guy Bedford committed 2020-09-28 18:27:25 -07:00
1 parent 062b35d4e8
commit 1e8cb08edc
20 files changed
+1935 -94

No files matched your search

+5 -1
View File
@@ -78,6 +78,9 @@ void NativeModuleLoader::InitializeModuleCategories() {
"internal/main/"
};
module_categories_.can_be_required.emplace(
"internal/deps/cjs-module-lexer/lexer");
module_categories_.cannot_be_required = std::set<std::string> {
#if !HAVE_INSPECTOR
"inspector",
@@ -118,7 +121,8 @@ void NativeModuleLoader::InitializeModuleCategories() {
if (prefix.length() > id.length()) {
continue;
}
if (id.find(prefix) == 0) {
if (id.find(prefix) == 0 &&
module_categories_.can_be_required.count(id) == 0) {
module_categories_.cannot_be_required.emplace(id);
}
}