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
Backport-PR-URL: #50669
Fixes: #49695
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
  • Loading branch information
aduh95 authored and targos committed Nov 23, 2023
1 parent 12cb700 commit 46d730a
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 @@ -1455,7 +1455,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 46d730a

Please sign in to comment.