Skip to content

Commit

Permalink
esm: fix return type of import.meta.resolve
Browse files Browse the repository at this point in the history
PR-URL: #49698
Fixes: #49695
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Guy Bedford <[email protected]>
  • Loading branch information
aduh95 authored and ruyadorno committed Sep 28, 2023
1 parent e5185b0 commit 8a6f5fb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ E('ERR_MISSING_ARGS',
E('ERR_MISSING_OPTION', '%s is required', TypeError);
E('ERR_MODULE_NOT_FOUND', function(path, base, exactUrl) {
if (exactUrl) {
lazyInternalUtil().setOwnProperty(this, 'url', exactUrl);
lazyInternalUtil().setOwnProperty(this, 'url', `${exactUrl}`);
}
return `Cannot find ${
exactUrl ? 'module' : 'package'} '${path}' imported from ${base}`;
Expand Down
6 changes: 2 additions & 4 deletions test/es-module/test-esm-import-meta-resolve.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ const fixtures = dirname.slice(0, dirname.lastIndexOf('/', dirname.length - 2) +

assert.strictEqual(import.meta.resolve('./test-esm-import-meta.mjs'),
dirname + 'test-esm-import-meta.mjs');
const notFound = import.meta.resolve('./notfound.mjs');
assert.strictEqual(new URL(notFound).href, new URL('./notfound.mjs', import.meta.url).href);
const noExtension = import.meta.resolve('./asset');
assert.strictEqual(new URL(noExtension).href, new URL('./asset', import.meta.url).href);
assert.strictEqual(import.meta.resolve('./notfound.mjs'), new URL('./notfound.mjs', import.meta.url).href);
assert.strictEqual(import.meta.resolve('./asset'), new URL('./asset', import.meta.url).href);
try {
import.meta.resolve('does-not-exist');
assert.fail();
Expand Down

0 comments on commit 8a6f5fb

Please sign in to comment.