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: nodejs/node#49698
Backport-PR-URL: nodejs/node#50669
Fixes: nodejs/node#49695
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
  • Loading branch information
sercher committed Apr 25, 2024
1 parent 6809ead commit b04a64e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion graal-nodejs/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 graal-nodejs/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 b04a64e

Please sign in to comment.