From 32dda85e8da10a270c887bcb44c3927187cdf45c Mon Sep 17 00:00:00 2001 From: Sergey Chernyshev Date: Thu, 25 Apr 2024 02:40:25 +0200 Subject: [PATCH] esm: fix return type of `import.meta.resolve` PR-URL: https://github.com/nodejs/node/pull/49698 Backport-PR-URL: https://github.com/nodejs/node/pull/50669 Fixes: https://github.com/nodejs/node/issues/49695 Reviewed-By: Geoffrey Booth Reviewed-By: Guy Bedford --- graal-nodejs/lib/internal/errors.js | 2 +- .../test/es-module/test-esm-import-meta-resolve.mjs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/graal-nodejs/lib/internal/errors.js b/graal-nodejs/lib/internal/errors.js index 4a95422255f..8f02e35317b 100644 --- a/graal-nodejs/lib/internal/errors.js +++ b/graal-nodejs/lib/internal/errors.js @@ -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}`; diff --git a/graal-nodejs/test/es-module/test-esm-import-meta-resolve.mjs b/graal-nodejs/test/es-module/test-esm-import-meta-resolve.mjs index 432d33f92b4..7bd1a65fbb7 100644 --- a/graal-nodejs/test/es-module/test-esm-import-meta-resolve.mjs +++ b/graal-nodejs/test/es-module/test-esm-import-meta-resolve.mjs @@ -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();