Skip to content

Commit 80f3074

Browse files
cjihrigBridgeAR
authored andcommitted
esm: use correct error arguments
ERR_UNKNOWN_FILE_EXTENSION expects a single argument. This commit fixes the argument count. PR-URL: #27763Fixes: #27761 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
1 parent 7e75086 commit 80f3074

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎lib/internal/modules/esm/default_resolve.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ function resolve(specifier, parentURL) {
9191
if(isMain)
9292
format=type===TYPE_MODULE ? 'module' : 'commonjs';
9393
else
94-
thrownewERR_UNKNOWN_FILE_EXTENSION(fileURLToPath(url),
95-
fileURLToPath(parentURL));
94+
thrownewERR_UNKNOWN_FILE_EXTENSION(fileURLToPath(url));
9695
}
9796
return{url: `${url}`, format };
9897
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
require('../common');
3+
constfixtures=require('../common/fixtures');
4+
constassert=require('assert');
5+
const{ spawnSync }=require('child_process');
6+
constfixture=fixtures.path('/es-modules/import-invalid-ext.mjs');
7+
constchild=spawnSync(process.execPath,['--experimental-modules',fixture]);
8+
consterrMsg='TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension';
9+
10+
assert.strictEqual(child.status,1);
11+
assert.strictEqual(child.signal,null);
12+
assert.strictEqual(child.stdout.toString().trim(),'');
13+
assert(child.stderr.toString().includes(errMsg));
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import'./simple.wat';

0 commit comments

Comments
 (0)