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

Function getOrInitializeCascadedLoader

lib/internal/modules/esm/loader.js:955–967  ·  view source on GitHub ↗

* This is a singleton ESM loader that integrates the loader hooks, if any. * It it used by other internal built-ins when they need to load user-land ESM code * while also respecting hooks. * When built-ins need access to this loader, they should do * require('internal/module/esm/loader').getOrIn

(asyncLoaderHooks)

Source from the content-addressed store, hash-verified

953 * @returns {ModuleLoader}
954 */
955function getOrInitializeCascadedLoader(asyncLoaderHooks) {
956 if (!cascadedLoader) {
957 cascadedLoader = createModuleLoader(asyncLoaderHooks);
958 // import.meta.resolve is not allowed in the async loader hook worker thread.
959 // So only set up the import.meta.resolve initializer when we are initializing
960 // the non-loader-hook-thread cascaded loader. When the native land doesn't see it,
961 // it knows the loader is running on the loader hook thread.
962 if (!(asyncLoaderHooks?.isForAsyncLoaderHookWorker)) {
963 setImportMetaResolveInitializer(createImportMetaResolve.bind(null, cascadedLoader));
964 }
965 }
966 return cascadedLoader;
967}
968
969function isCascadedLoaderInitialized() {
970 return cascadedLoader !== undefined;

Callers 2

registerFunction · 0.85

Calls 2

createModuleLoaderFunction · 0.85
bindMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…