Skip to content

modules: reduce circular dependency of internal/modules/cjs/loader

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 of hasLoadedAnyUserCJSModule for documentation purposes.

Inspired by https://github.com/nodejs/help/issues/2259

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading