(options)
| 218 | } |
| 219 | |
| 220 | function initializeModuleLoaders(options) { |
| 221 | const { shouldSpawnLoaderHookWorker, shouldPreloadModules } = options; |
| 222 | // Initialize certain special module.Module properties and the CJS conditions. |
| 223 | const { initializeCJS } = require('internal/modules/cjs/loader'); |
| 224 | initializeCJS(); |
| 225 | // Initialize the ESM loader and a few module callbacks. |
| 226 | // If shouldSpawnLoaderHookWorker is true, later when the ESM loader is instantiated on-demand, |
| 227 | // it will spawn a loader worker thread to handle async custom loader hooks. |
| 228 | const { initializeESM } = require('internal/modules/esm/utils'); |
| 229 | initializeESM(shouldSpawnLoaderHookWorker); |
| 230 | |
| 231 | const { |
| 232 | hasStartedUserCJSExecution, |
| 233 | hasStartedUserESMExecution, |
| 234 | } = require('internal/modules/helpers'); |
| 235 | // At this point, no user module has been executed yet. |
| 236 | assert(!hasStartedUserCJSExecution()); |
| 237 | assert(!hasStartedUserESMExecution()); |
| 238 | |
| 239 | if (getEmbedderOptions().hasEmbedderPreload) { |
| 240 | runEmbedderPreload(); |
| 241 | } |
| 242 | // Do not enable preload modules if custom loaders are disabled. |
| 243 | // For example, loader workers are responsible for doing this themselves. |
| 244 | // And preload modules are not supported in ShadowRealm as well. |
| 245 | if (shouldPreloadModules) { |
| 246 | loadPreloadModules(); |
| 247 | } |
| 248 | // Need to be done after --require setup. |
| 249 | initializeFrozenIntrinsics(); |
| 250 | } |
| 251 | |
| 252 | function refreshRuntimeOptions() { |
| 253 | refreshOptions(); |
no test coverage detected
searching dependent graphs…