MCPcopy Create free account
hub / github.com/nodejs/node / register

Method register

lib/internal/modules/esm/hooks.js:173–183  ·  view source on GitHub ↗

* Import and register custom/user-defined module loader hook(s). * @param {string} urlOrSpecifier * @param {string} parentURL * @param {any} [data] Arbitrary data to be passed from the custom * loader (user-land) to the worker.

(urlOrSpecifier, parentURL, data, isInternal)

Source from the content-addressed store, hash-verified

171 * loader (user-land) to the worker.
172 */
173 async register(urlOrSpecifier, parentURL, data, isInternal) {
174 const cascadedLoader = require('internal/modules/esm/loader').getOrInitializeCascadedLoader();
175 const keyedExports = isInternal ?
176 require(urlOrSpecifier) :
177 await cascadedLoader.import(
178 urlOrSpecifier,
179 parentURL,
180 kEmptyObject,
181 );
182 await this.addCustomLoader(urlOrSpecifier, keyedExports, data);
183 }
184
185 /**
186 * Collect custom/user-defined module loader hook(s).

Calls 3

addCustomLoaderMethod · 0.95
importMethod · 0.80
requireFunction · 0.50

Tested by

no test coverage detected