Skip to content

Commit

Permalink
fixup! module: detect ESM syntax by trying to recompile as SourceText…
Browse files Browse the repository at this point in the history
…Module
  • Loading branch information
joyeecheung committed Apr 12, 2024
1 parent dc9f175 commit 6eec04e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/internal/modules/run_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function executeUserEntryPoint(main = process.argv[1]) {
const { shouldRetryAsESM } = internalBinding('contextify');
const mainPath = resolvedMain || main;
mainURL = pathToFileURL(mainPath).href;
retryAsESM = shouldRetryAsESM(error.message, cjsLoader.entryPointSource, mainPath);
retryAsESM = shouldRetryAsESM(error.message, cjsLoader.entryPointSource, mainURL);
// In case the entry point is a large file, such as a bundle,
// ensure no further references can prevent it being garbage-collected.
cjsLoader.entryPointSource = undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,7 @@ static void ContainsModuleSyntax(const FunctionCallbackInfo<Value>& args) {
CHECK(args[1]->IsString());
Local<String> filename = args[1].As<String>();

// Argument 2: resource name (URL for module).
// Argument 2: resource name (URL for ES module).
Local<String> resource_name = filename;
if (args[2]->IsString()) {
resource_name = args[2].As<String>();
Expand Down

0 comments on commit 6eec04e

Please sign in to comment.