* @param {function(ModuleLoader):ModuleWrap|undefined} callback
(callback)
| 87 | * @param {function(ModuleLoader):ModuleWrap|undefined} callback |
| 88 | */ |
| 89 | async 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 |
no test coverage detected
searching dependent graphs…