MCPcopy Index your code
hub / github.com/nodejs/node / registerModule

Function registerModule

lib/internal/modules/esm/utils.js:170–185  ·  view source on GitHub ↗

* V8 would make sure that as long as import() can still be initiated from * the referrer, the symbol referenced by |host_defined_option_symbol| should * be alive, which in term would keep the settings object alive through the * WeakMap, and in turn that keeps the referrer object alive, which woul

(referrer, registry)

Source from the content-addressed store, hash-verified

168 * @param {ModuleRegistry} registry
169 */
170function registerModule(referrer, registry) {
171 const idSymbol = referrer[host_defined_option_symbol];
172 if (idSymbol === vm_dynamic_import_no_callback ||
173 idSymbol === vm_dynamic_import_missing_flag ||
174 idSymbol === vm_dynamic_import_main_context_default ||
175 idSymbol === vm_dynamic_import_default_internal) {
176 // The referrer is compiled without custom callbacks, so there is
177 // no registry to hold on to. We'll throw
178 // ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING when a callback is
179 // needed.
180 return;
181 }
182 // To prevent it from being GC'ed.
183 registry.callbackReferrer ??= referrer;
184 moduleRegistries.set(idSymbol, registry);
185}
186
187/**
188 * Initializes the `import.meta` object for a given module. This is only called when the module

Callers 3

createDynamicModuleFunction · 0.85
constructorMethod · 0.85

Calls 1

setMethod · 0.45

Tested by

no test coverage detected