* Prepare to run CommonJS code. * This function is called during pre-execution, before any user code is run. * @returns {void}
()
| 489 | * @returns {void} |
| 490 | */ |
| 491 | function 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. |
no test coverage detected
searching dependent graphs…