node/lib/internal/modules
Joyee Cheung d080f0db1f
module: unify TypeScript and .mjs handling in CommonJS
This refactors the CommonJS loading a bit to create a center point
that handles source loading (`loadSource`) and make format detection
more consistent to pave the way for future synchronous hooks.

- Handle .mjs in the .js handler, similar to how .cjs has been handled.
- Generate the legacy ERR_REQUIRE_ESM in a getRequireESMError() for
  both .mts and require(esm) handling (when it's disabled).

PR-URL: https://github.com/nodejs/node/pull/55590
Refs: https://github.com/nodejs/loaders/pull/198
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
2024-10-31 15:43:57 +00:00
..
cjs module: unify TypeScript and .mjs handling in CommonJS 2024-10-31 15:43:57 +00:00
esm module: fix error thrown from require(esm) hitting TLA repeatedly 2024-10-29 21:15:19 +00:00
helpers.js module: add module.stripTypeScriptTypes 2024-10-24 18:27:58 +00:00
package_json_reader.js module: add findPackageJSON util 2024-10-25 20:40:54 +00:00
run_main.js module: support loading entrypoint as url 2024-09-27 15:26:48 +08:00
typescript.js module: add module.stripTypeScriptTypes 2024-10-24 18:27:58 +00:00