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

Function initializeCJS

lib/internal/modules/cjs/loader.js:491–515  ·  view source on GitHub ↗

* Prepare to run CommonJS code. * This function is called during pre-execution, before any user code is run. * @returns {void}

()

Source from the content-addressed store, hash-verified

489 * @returns {void}
490 */
491function initializeCJS() {
492 // This need to be done at runtime in case --expose-internals is set.
493
494 let modules = Module.builtinModules = BuiltinModule.getAllBuiltinModuleIds();
495 if (!getOptionValue('--experimental-quic')) {
496 modules = modules.filter((i) => i !== 'node:quic');
497 }
498 if (!getOptionValue('--experimental-ffi')) {
499 modules = modules.filter((i) => i !== 'node:ffi');
500 }
501 if (!getOptionValue('--experimental-vfs')) {
502 modules = modules.filter((i) => i !== 'node:vfs');
503 }
504 Module.builtinModules = ObjectFreeze(modules);
505
506 initializeCjsConditions();
507
508 if (!getEmbedderOptions().noGlobalSearchPaths) {
509 Module._initPaths();
510 }
511
512 // TODO(joyeecheung): deprecate this in favor of a proper hook?
513 Module.runMain =
514 require('internal/modules/run_main').executeUserEntryPoint;
515}
516
517// Given a module name, and a list of paths to test, returns the first
518// matching file in the following precedence.

Callers 1

initializeModuleLoadersFunction · 0.85

Calls 6

getOptionValueFunction · 0.85
initializeCjsConditionsFunction · 0.85
getEmbedderOptionsFunction · 0.85
filterMethod · 0.65
requireFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…