From 1a6e9450b8dabfe31c0b71dbd0ab8d1230f7a06e Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sun, 13 Aug 2023 06:23:05 +0200 Subject: [PATCH] module: make CJS load from ESM loader PR-URL: https://github.com/nodejs/node/pull/47999 Reviewed-By: Geoffrey Booth Reviewed-By: Jacob Smith --- doc/api/esm.md | 50 ++++- lib/internal/modules/esm/load.js | 74 +++++- lib/internal/modules/esm/loader.js | 51 +++-- lib/internal/modules/esm/module_job.js | 25 ++- lib/internal/modules/esm/translators.js | 210 ++++++++++++++---- test/es-module/test-esm-loader-hooks.mjs | 41 ++++ test/es-module/test-esm-named-exports.js | 11 + .../builtin-named-exports-loader.mjs | 17 +- .../not-found-assert-loader.mjs | 22 +- test/fixtures/require-resolve.js | 30 +-- 10 files changed, 426 insertions(+), 105 deletions(-) create mode 100644 test/es-module/test-esm-named-exports.js diff --git a/doc/api/esm.md b/doc/api/esm.md index 6d510d0d0b00b5..f313195df0055f 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -908,6 +908,9 @@ export function resolve(specifier, context, nextResolve) {