mirror of
https://github.com/nodejs/node.git
synced 2025-05-11 01:27:14 +00:00

Previously `internal/bootstrap/pre_execution.js` requires `internal/modules/cjs/loader.js` which in turn requires `internal/bootstrap/pre_execution.js`. This patch moves the entry point execution logic out of `pre_execution.js` and puts it into `internal/modules/run_main.js`. It also tests that `Module.runMain` can be monkey-patched before further deprecation/refactoring can be done. Also added an internal assertion `hasLoadedAnyUserCJSModule` for documentation purposes. PR-URL: https://github.com/nodejs/node/pull/30349 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
18 lines
632 B
JavaScript
18 lines
632 B
JavaScript
'use strict';
|
|
|
|
const {
|
|
prepareMainThreadExecution
|
|
} = require('internal/bootstrap/pre_execution');
|
|
|
|
prepareMainThreadExecution(true);
|
|
|
|
markBootstrapComplete();
|
|
|
|
// Note: this loads the module through the ESM loader if the module is
|
|
// determined to be an ES module. This hangs from the CJS module loader
|
|
// because we currently allow monkey-patching of the module loaders
|
|
// in the preloaded scripts through require('module').
|
|
// runMain here might be monkey-patched by users in --require.
|
|
// XXX: the monkey-patchability here should probably be deprecated.
|
|
require('internal/modules/cjs/loader').Module.runMain(process.argv[1]);
|