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

Function initializeModuleLoaders

lib/internal/process/pre_execution.js:220–250  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

218}
219
220function 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
252function refreshRuntimeOptions() {
253 refreshOptions();

Callers 4

worker_thread.jsFile · 0.85
prepareExecutionFunction · 0.85

Calls 10

initializeCJSFunction · 0.85
initializeESMFunction · 0.85
getEmbedderOptionsFunction · 0.85
runEmbedderPreloadFunction · 0.85
loadPreloadModulesFunction · 0.85
requireFunction · 0.50
assertFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…