Skip to content

Commit f67af84

Browse files
committed
src: merge NativeModuleEnv into NativeModuleLoader
nodejs/node#43824
1 parent b25a71a commit f67af84

File tree

4 files changed

+60
-3
lines changed

4 files changed

+60
-3
lines changed

patches/node/.patches

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ fixup_for_wc_98-compat-extra-semi.patch
4646
drop_deserializerequest_move_constructor_for_c_20_compat.patch
4747
fix_parallel_test-v8-stats.patch
4848
fix_expose_the_built-in_electron_module_via_the_esm_loader.patch
49+
api_pass_oomdetails_to_oomerrorcallback.patch
50+
src_iwyu_in_cleanup_queue_cc.patch
51+
fix_expose_lookupandcompile_with_parameters.patch
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Shelley Vohr <[email protected]>
3+
Date: Thu, 13 Oct 2022 17:10:01 +0200
4+
Subject: fix: expose LookupAndCompile with parameters
5+
6+
Node.js removed custom parameters from the public version of LookupAndCompile,
7+
which we use in Electron. This patch re-exposes a wrapper to allow custom
8+
parameters.
9+
10+
This should be upstreamed.
11+
12+
diff --git a/src/node_builtins.cc b/src/node_builtins.cc
13+
index 3bc9d113b6b818dcda332966f09f17248b421263..549339b5b677fa242a7b60ae716789c2a11ab18d 100644
14+
--- a/src/node_builtins.cc
15+
+++ b/src/node_builtins.cc
16+
@@ -397,6 +397,22 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
17+
return maybe;
18+
}
19+
20+
+MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
21+
+ Local<Context> context,
22+
+ const char* id,
23+
+ std::vector<Local<String>>* parameters,
24+
+ Environment* optional_env) {
25+
+ Result result;
26+
+ Isolate* isolate = context->GetIsolate();
27+
+
28+
+ MaybeLocal<Function> maybe = GetInstance()->LookupAndCompileInternal(
29+
+ context, id, parameters, &result);
30+
+ if (optional_env != nullptr) {
31+
+ RecordResult(id, result, optional_env);
32+
+ }
33+
+ return maybe;
34+
+}
35+
+
36+
bool BuiltinLoader::CompileAllBuiltins(Local<Context> context) {
37+
BuiltinLoader* loader = GetInstance();
38+
std::vector<std::string> ids = loader->GetBuiltinIds();
39+
diff --git a/src/node_builtins.h b/src/node_builtins.h
40+
index 7f0a25af306ffefbc51ac43689ed208d4cd94f0b..a32a7a990082ea3dad73511f91a9c70c72f6fe31 100644
41+
--- a/src/node_builtins.h
42+
+++ b/src/node_builtins.h
43+
@@ -49,6 +49,11 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
44+
v8::Local<v8::Context> context,
45+
const char* id,
46+
Environment* optional_env);
47+
+ static v8::MaybeLocal<v8::Function> LookupAndCompile(
48+
+ v8::Local<v8::Context> context,
49+
+ const char* id,
50+
+ std::vector<v8::Local<v8::String>>* parameters,
51+
+ Environment* optional_env);
52+
53+
static v8::Local<v8::Object> GetSourceObject(v8::Local<v8::Context> context);
54+
// Returns config.gypi as a JSON string

shell/common/node_includes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
#include "env.h"
2121
#include "node.h"
2222
#include "node_buffer.h"
23+
#include "node_builtins.h"
2324
#include "node_errors.h"
2425
#include "node_internals.h"
25-
#include "node_native_module_env.h"
2626
#include "node_object_wrap.h"
2727
#include "node_options-inl.h"
2828
#include "node_options.h"

shell/common/node_util.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ v8::MaybeLocal<v8::Value> CompileAndCall(
1818
v8::Isolate* isolate = context->GetIsolate();
1919
v8::TryCatch try_catch(isolate);
2020
v8::MaybeLocal<v8::Function> compiled =
21-
node::native_module::NativeModuleEnv::LookupAndCompile(
22-
context, id, parameters, optional_env);
21+
node::builtins::BuiltinLoader::LookupAndCompile(context, id, parameters,
22+
optional_env);
2323
if (compiled.IsEmpty()) {
2424
return v8::MaybeLocal<v8::Value>();
2525
}

0 commit comments

Comments
 (0)