module: move helpers out of CommonJS loader
Following up #49869, supporting #49432, this PR moves some methods that are used by both the CommonJS and ESM startup flows out of cjs/loader.js
and into shared common files. This is a precursor for the next PR that refactors how the initial entry point is handled in ESM-first mode.
All this PR does is move the code; nothing is changed other than references to variables. @nodejs/loaders