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

Function asyncRunEntryPointWithESMLoader

lib/internal/modules/run_main.js:89–112  ·  view source on GitHub ↗

* @param {function(ModuleLoader):ModuleWrap|undefined} callback

(callback)

Source from the content-addressed store, hash-verified

87 * @param {function(ModuleLoader):ModuleWrap|undefined} callback
88 */
89async function asyncRunEntryPointWithESMLoader(callback) {
90 const cascadedLoader = require('internal/modules/esm/loader').getOrInitializeCascadedLoader();
91 try {
92 const userImports = getOptionValue('--import');
93 if (userImports.length > 0) {
94 const parentURL = getCWDURL().href;
95 for (let i = 0; i < userImports.length; i++) {
96 await cascadedLoader.import(userImports[i], parentURL, kEmptyObject);
97 }
98 } else {
99 cascadedLoader.waitForAsyncLoaderHookInitialization();
100 }
101 await callback(cascadedLoader);
102 } catch (err) {
103 if (hasUncaughtExceptionCaptureCallback()) {
104 process._fatalException(err);
105 return;
106 }
107 triggerUncaughtException(
108 err,
109 true, /* fromPromise */
110 );
111 }
112}
113
114/**
115 * This initializes the ESM loader and runs --import (if any) before executing the

Callers 1

Calls 7

getOptionValueFunction · 0.85
getCWDURLFunction · 0.85
importMethod · 0.80
requireFunction · 0.70
callbackFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…