Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1d16976

Browse filesBrowse files
aduh95targos
authored andcommitted
module: report unfinished TLA in ambiguous modules
PR-URL: #54980 Fixes: #54931 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent fc90d7c commit 1d16976
Copy full SHA for 1d16976

File tree

Expand file treeCollapse file tree

3 files changed

+14
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+14
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/modules/cjs/loader.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/cjs/loader.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ function loadESMFromCJS(mod, filename) {
13701370
if (isMain) {
13711371
require('internal/modules/run_main').runEntryPointWithESMLoader((cascadedLoader) => {
13721372
const mainURL = pathToFileURL(filename).href;
1373-
cascadedLoader.import(mainURL, undefined, { __proto__: null }, true);
1373+
return cascadedLoader.import(mainURL, undefined, { __proto__: null }, true);
13741374
});
13751375
// ESM won't be accessible via process.mainModule.
13761376
setOwnProperty(process, 'mainModule', undefined);
Collapse file

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

Copy file name to clipboardExpand all lines: test/es-module/test-esm-detect-ambiguous.mjs
+12Lines 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',
Collapse file
+1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.