mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
module: report unfinished TLA in ambiguous modules
PR-URL: https://github.com/nodejs/node/pull/54980 Fixes: https://github.com/nodejs/node/issues/54931 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
parent
6031a4bc7c
commit
be4babb3c2
@ -1381,7 +1381,7 @@ function loadESMFromCJS(mod, filename) {
|
||||
if (isMain) {
|
||||
require('internal/modules/run_main').runEntryPointWithESMLoader((cascadedLoader) => {
|
||||
const mainURL = pathToFileURL(filename).href;
|
||||
cascadedLoader.import(mainURL, undefined, { __proto__: null }, true);
|
||||
return cascadedLoader.import(mainURL, undefined, { __proto__: null }, true);
|
||||
});
|
||||
// ESM won't be accessible via process.mainModule.
|
||||
setOwnProperty(process, 'mainModule', undefined);
|
||||
|
@ -252,6 +252,18 @@ describe('Module syntax detection', { concurrency: !process.env.TEST_PARALLEL },
|
||||
strictEqual(signal, null);
|
||||
});
|
||||
|
||||
it('reports unfinished top-level `await`', async () => {
|
||||
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
|
||||
'--no-warnings',
|
||||
fixtures.path('es-modules/tla/unresolved.js'),
|
||||
]);
|
||||
|
||||
strictEqual(stderr, '');
|
||||
strictEqual(stdout, '');
|
||||
strictEqual(code, 13);
|
||||
strictEqual(signal, null);
|
||||
});
|
||||
|
||||
it('permits top-level `await` above import/export syntax', async () => {
|
||||
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
|
||||
'--eval',
|
||||
|
1
test/fixtures/es-modules/tla/unresolved.js
vendored
Normal file
1
test/fixtures/es-modules/tla/unresolved.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
await new Promise(() => {});
|
Loading…
Reference in New Issue
Block a user