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: #27763 Fixes: #27761 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent 7e75086 commit 80f3074

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

lib/internal/modules/esm/default_resolve.js

+1-2
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-
throw new ERR_UNKNOWN_FILE_EXTENSION(fileURLToPath(url),
95-
fileURLToPath(parentURL));
94+
throw new ERR_UNKNOWN_FILE_EXTENSION(fileURLToPath(url));
9695
}
9796
return { url: `${url}`, format };
9897
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
require('../common');
3+
const fixtures = require('../common/fixtures');
4+
const assert = require('assert');
5+
const { spawnSync } = require('child_process');
6+
const fixture = fixtures.path('/es-modules/import-invalid-ext.mjs');
7+
const child = spawnSync(process.execPath, ['--experimental-modules', fixture]);
8+
const errMsg = '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));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './simple.wat';

0 commit comments

Comments
 (0)