Skip to content

Commit fb7c437

Browse files
committed
src: make LoadEnvironment with string work with builtin modules path
Fixes: #40605 PR-URL: #40607 Reviewed-By: Geoffrey Booth <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent bbc10f1 commit fb7c437

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/node_native_module.cc

+10-7
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,16 @@ static std::string OnDiskFileName(const char* id) {
207207
MaybeLocal<String> NativeModuleLoader::LoadBuiltinModuleSource(Isolate* isolate,
208208
const char* id) {
209209
#ifdef NODE_BUILTIN_MODULES_PATH
210+
if (strncmp(id, "embedder_main_", strlen("embedder_main_")) == 0) {
211+
#endif // NODE_BUILTIN_MODULES_PATH
212+
const auto source_it = source_.find(id);
213+
if (UNLIKELY(source_it == source_.end())) {
214+
fprintf(stderr, "Cannot find native builtin: \"%s\".\n", id);
215+
ABORT();
216+
}
217+
return source_it->second.ToStringChecked(isolate);
218+
#ifdef NODE_BUILTIN_MODULES_PATH
219+
}
210220
std::string filename = OnDiskFileName(id);
211221

212222
std::string contents;
@@ -222,13 +232,6 @@ MaybeLocal<String> NativeModuleLoader::LoadBuiltinModuleSource(Isolate* isolate,
222232
}
223233
return String::NewFromUtf8(
224234
isolate, contents.c_str(), v8::NewStringType::kNormal, contents.length());
225-
#else
226-
const auto source_it = source_.find(id);
227-
if (UNLIKELY(source_it == source_.end())) {
228-
fprintf(stderr, "Cannot find native builtin: \"%s\".\n", id);
229-
ABORT();
230-
}
231-
return source_it->second.ToStringChecked(isolate);
232235
#endif // NODE_BUILTIN_MODULES_PATH
233236
}
234237

0 commit comments

Comments
 (0)