11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst { RegExpPrototypeExec } = primordials;
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst {
61cb0ef41Sopenharmony_ci  prepareMainThreadExecution,
71cb0ef41Sopenharmony_ci  markBootstrapComplete,
81cb0ef41Sopenharmony_ci} = require('internal/process/pre_execution');
91cb0ef41Sopenharmony_ciconst { getOptionValue } = require('internal/options');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst mainEntry = prepareMainThreadExecution(true);
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_cimarkBootstrapComplete();
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci// Necessary to reset RegExp statics before user code runs.
161cb0ef41Sopenharmony_ciRegExpPrototypeExec(/^/, '');
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ciif (getOptionValue('--experimental-default-type') === 'module') {
191cb0ef41Sopenharmony_ci  require('internal/modules/run_main').executeUserEntryPoint(mainEntry);
201cb0ef41Sopenharmony_ci} else {
211cb0ef41Sopenharmony_ci  /**
221cb0ef41Sopenharmony_ci   * To support legacy monkey-patching of `Module.runMain`, we call `runMain` here to have the CommonJS loader begin
231cb0ef41Sopenharmony_ci   * the execution of the main entry point, even if the ESM loader immediately takes over because the main entry is an
241cb0ef41Sopenharmony_ci   * ES module or one of the other opt-in conditions (such as the use of `--import`) are met. Users can monkey-patch
251cb0ef41Sopenharmony_ci   * before the main entry point is loaded by doing so via scripts loaded through `--require`. This monkey-patchability
261cb0ef41Sopenharmony_ci   * is undesirable and is removed in `--experimental-default-type=module` mode.
271cb0ef41Sopenharmony_ci   */
281cb0ef41Sopenharmony_ci  require('internal/modules/cjs/loader').Module.runMain(mainEntry);
291cb0ef41Sopenharmony_ci}
30