Skip to content

Commit 20b996d

Browse files
authored
esm: fix return type of import.meta.resolve
PR-URL: #49698 Fixes: #49695 Reviewed-By: Geoffrey Booth <[email protected]> Reviewed-By: Guy Bedford <[email protected]>
1 parent cdad3d8 commit 20b996d

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

lib/internal/errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,7 @@ E('ERR_MISSING_ARGS',
14501450
E('ERR_MISSING_OPTION', '%s is required', TypeError);
14511451
E('ERR_MODULE_NOT_FOUND', function(path, base, exactUrl) {
14521452
if (exactUrl) {
1453-
lazyInternalUtil().setOwnProperty(this, 'url', exactUrl);
1453+
lazyInternalUtil().setOwnProperty(this, 'url', `${exactUrl}`);
14541454
}
14551455
return `Cannot find ${
14561456
exactUrl ? 'module' : 'package'} '${path}' imported from ${base}`;

test/es-module/test-esm-import-meta-resolve.mjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ const fixtures = dirname.slice(0, dirname.lastIndexOf('/', dirname.length - 2) +
99

1010
assert.strictEqual(import.meta.resolve('./test-esm-import-meta.mjs'),
1111
dirname + 'test-esm-import-meta.mjs');
12-
const notFound = import.meta.resolve('./notfound.mjs');
13-
assert.strictEqual(new URL(notFound).href, new URL('./notfound.mjs', import.meta.url).href);
14-
const noExtension = import.meta.resolve('./asset');
15-
assert.strictEqual(new URL(noExtension).href, new URL('./asset', import.meta.url).href);
12+
assert.strictEqual(import.meta.resolve('./notfound.mjs'), new URL('./notfound.mjs', import.meta.url).href);
13+
assert.strictEqual(import.meta.resolve('./asset'), new URL('./asset', import.meta.url).href);
1614
try {
1715
import.meta.resolve('does-not-exist');
1816
assert.fail();

0 commit comments

Comments
 (0)