diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 87200b40d45bdc..b971b0ba54b075 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -1338,7 +1338,12 @@ E('ERR_IMPORT_ATTRIBUTE_MISSING', E('ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE', 'Module "%s" is not of type "%s"', TypeError); E('ERR_IMPORT_ATTRIBUTE_UNSUPPORTED', - 'Import attribute "%s" with value "%s" is not supported', TypeError); + function error(attribute, value, url = undefined) { + if (url === undefined) { + return `Import attribute "${attribute}" with value "${value}" is not supported`; + } + return `Import attribute "${attribute}" with value "${value}" is not supported in ${url}`; + }, TypeError); E('ERR_INCOMPATIBLE_OPTION_PAIR', 'Option "%s" cannot be used in combination with option "%s"', TypeError, HideStackFramesError); E('ERR_INPUT_TYPE_NOT_ALLOWED', '--input-type can only be used with string ' + diff --git a/lib/internal/modules/esm/assert.js b/lib/internal/modules/esm/assert.js index 1a96569cce109f..a8e564d6707285 100644 --- a/lib/internal/modules/esm/assert.js +++ b/lib/internal/modules/esm/assert.js @@ -57,7 +57,7 @@ function validateAttributes(url, format, const keys = ObjectKeys(importAttributes); for (let i = 0; i < keys.length; i++) { if (keys[i] !== 'type') { - throw new ERR_IMPORT_ATTRIBUTE_UNSUPPORTED(keys[i], importAttributes[keys[i]]); + throw new ERR_IMPORT_ATTRIBUTE_UNSUPPORTED(keys[i], importAttributes[keys[i]], url); } } const validType = formatTypeMap[format]; @@ -102,7 +102,7 @@ function handleInvalidType(url, type) { // `type` might not have been one of the types we understand. if (!ArrayPrototypeIncludes(supportedTypeAttributes, type)) { - throw new ERR_IMPORT_ATTRIBUTE_UNSUPPORTED('type', type); + throw new ERR_IMPORT_ATTRIBUTE_UNSUPPORTED('type', type, url); } // `type` was the wrong value for this format.