Skip to content

Commit 249d82b

Browse files
aduh95marco-ippolito
authored andcommitted
module: report unfinished TLA in ambiguous modules
PR-URL: #54980 Backport-PR-URL: #56927 Fixes: #54931 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Refs: #52697
1 parent 1925d72 commit 249d82b

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

lib/internal/modules/cjs/loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ function loadESMFromCJS(mod, filename) {
13361336
if (isMain) {
13371337
require('internal/modules/run_main').runEntryPointWithESMLoader((cascadedLoader) => {
13381338
const mainURL = pathToFileURL(filename).href;
1339-
cascadedLoader.import(mainURL, undefined, { __proto__: null }, true);
1339+
return cascadedLoader.import(mainURL, undefined, { __proto__: null }, true);
13401340
});
13411341
// ESM won't be accessible via process.mainModule.
13421342
setOwnProperty(process, 'mainModule', undefined);

test/es-module/test-esm-detect-ambiguous.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,18 @@ describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL },
252252
strictEqual(signal, null);
253253
});
254254

255+
it('reports unfinished top-level `await`', async () => {
256+
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
257+
'--no-warnings',
258+
fixtures.path('es-modules/tla/unresolved.js'),
259+
]);
260+
261+
strictEqual(stderr, '');
262+
strictEqual(stdout, '');
263+
strictEqual(code, 13);
264+
strictEqual(signal, null);
265+
});
266+
255267
it('permits top-level `await` above import/export syntax', async () => {
256268
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
257269
'--eval',
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
await new Promise(() => {});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy