Skip to content

Commit dd77c05

Browse files
joyeecheungtargos
authored andcommitted
bootstrap: support module_wrap binding in snapshot
PR-URL: #45849 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent b93a967 commit dd77c05

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/module_wrap.cc

+20
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "memory_tracker-inl.h"
55
#include "node_contextify.h"
66
#include "node_errors.h"
7+
#include "node_external_reference.h"
78
#include "node_internals.h"
89
#include "node_process-inl.h"
910
#include "node_url.h"
@@ -811,8 +812,27 @@ void ModuleWrap::Initialize(Local<Object> target,
811812
#undef V
812813
}
813814

815+
void ModuleWrap::RegisterExternalReferences(
816+
ExternalReferenceRegistry* registry) {
817+
registry->Register(New);
818+
819+
registry->Register(Link);
820+
registry->Register(Instantiate);
821+
registry->Register(Evaluate);
822+
registry->Register(SetSyntheticExport);
823+
registry->Register(CreateCachedData);
824+
registry->Register(GetNamespace);
825+
registry->Register(GetStatus);
826+
registry->Register(GetError);
827+
registry->Register(GetStaticDependencySpecifiers);
828+
829+
registry->Register(SetImportModuleDynamicallyCallback);
830+
registry->Register(SetInitializeImportMetaObjectCallback);
831+
}
814832
} // namespace loader
815833
} // namespace node
816834

817835
NODE_BINDING_CONTEXT_AWARE_INTERNAL(module_wrap,
818836
node::loader::ModuleWrap::Initialize)
837+
NODE_BINDING_EXTERNAL_REFERENCE(
838+
module_wrap, node::loader::ModuleWrap::RegisterExternalReferences)

src/module_wrap.h

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
namespace node {
1212

1313
class Environment;
14+
class ExternalReferenceRegistry;
1415

1516
namespace contextify {
1617
class ContextifyContext;
@@ -44,6 +45,7 @@ class ModuleWrap : public BaseObject {
4445
v8::Local<v8::Value> unused,
4546
v8::Local<v8::Context> context,
4647
void* priv);
48+
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
4749
static void HostInitializeImportMetaObjectCallback(
4850
v8::Local<v8::Context> context,
4951
v8::Local<v8::Module> module,

src/node_external_reference.h

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class ExternalReferenceRegistry {
7474
V(heap_utils) \
7575
V(messaging) \
7676
V(mksnapshot) \
77+
V(module_wrap) \
7778
V(options) \
7879
V(os) \
7980
V(performance) \

0 commit comments

Comments
 (0)