From 425d8eea3930d53c0f27bcffd0ca49c473b0d49c Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sun, 14 Apr 2024 14:24:33 +0200 Subject: [PATCH] fixup! module: detect ESM syntax by trying to recompile as SourceTextModule Co-authored-by: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com> --- lib/internal/modules/run_main.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/internal/modules/run_main.js b/lib/internal/modules/run_main.js index fd592f45ffd3e9d..f6dcc5312921e9c 100644 --- a/lib/internal/modules/run_main.js +++ b/lib/internal/modules/run_main.js @@ -194,9 +194,7 @@ function executeUserEntryPoint(main = process.argv[1]) { if (useESMLoader || retryAsESM) { const mainPath = resolvedMain || main; - if (mainURL === undefined) { - mainURL = pathToFileURL(mainPath).href; - } + mainURL ??= pathToFileURL(mainPath).href; runEntryPointWithESMLoader((cascadedLoader) => { // Note that if the graph contains unsettled TLA, this may never resolve