node/lib/internal/main/run_main_module.js
Geoffrey Booth 94c327c753
module: remove --experimental-default-type
PR-URL: https://github.com/nodejs/node/pull/56092
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
2024-12-02 22:43:55 +00:00

33 lines
1.2 KiB
JavaScript

'use strict';
const {
RegExpPrototypeExec,
} = primordials;
const {
prepareMainThreadExecution,
markBootstrapComplete,
} = require('internal/process/pre_execution');
const { getOptionValue } = require('internal/options');
const { emitExperimentalWarning } = require('internal/util');
const isEntryURL = getOptionValue('--entry-url');
const mainEntry = prepareMainThreadExecution(!isEntryURL);
markBootstrapComplete();
// Necessary to reset RegExp statics before user code runs.
RegExpPrototypeExec(/^/, '');
if (isEntryURL) {
emitExperimentalWarning('--entry-url');
}
/**
* To support legacy monkey-patching of `Module.runMain`, we call `runMain` here to have the CommonJS loader begin the
* execution of the main entry point, even if the ESM loader immediately takes over because the main entry is an ES
* module or one of the other opt-in conditions (such as the use of `--import`) are met. Users can monkey-patch before
* the main entry point is loaded by doing so via scripts loaded through `--require`. This monkey-patchability is
* undesirable and should be removed once the module customization hooks provide equivalent functionality.
*/
require('internal/modules/cjs/loader').Module.runMain(mainEntry);