mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
esm: fix hook name in error message
PR-URL: https://github.com/nodejs/node/pull/50466 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
parent
c59fe11038
commit
ab857e138f
|
|
@ -1475,11 +1475,11 @@ E('ERR_INVALID_REPL_EVAL_CONFIG',
|
||||||
E('ERR_INVALID_REPL_INPUT', '%s', TypeError);
|
E('ERR_INVALID_REPL_INPUT', '%s', TypeError);
|
||||||
E('ERR_INVALID_RETURN_PROPERTY', (input, name, prop, value) => {
|
E('ERR_INVALID_RETURN_PROPERTY', (input, name, prop, value) => {
|
||||||
return `Expected a valid ${input} to be returned for the "${prop}" from the` +
|
return `Expected a valid ${input} to be returned for the "${prop}" from the` +
|
||||||
` "${name}" function but got ${determineSpecificType(value)}.`;
|
` "${name}" hook but got ${determineSpecificType(value)}.`;
|
||||||
}, TypeError);
|
}, TypeError);
|
||||||
E('ERR_INVALID_RETURN_PROPERTY_VALUE', (input, name, prop, value) => {
|
E('ERR_INVALID_RETURN_PROPERTY_VALUE', (input, name, prop, value) => {
|
||||||
return `Expected ${input} to be returned for the "${prop}" from the` +
|
return `Expected ${input} to be returned for the "${prop}" from the` +
|
||||||
` "${name}" function but got ${determineSpecificType(value)}.`;
|
` "${name}" hook but got ${determineSpecificType(value)}.`;
|
||||||
}, TypeError);
|
}, TypeError);
|
||||||
E('ERR_INVALID_RETURN_VALUE', (input, name, value) => {
|
E('ERR_INVALID_RETURN_VALUE', (input, name, value) => {
|
||||||
const type = determineSpecificType(value);
|
const type = determineSpecificType(value);
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ function assertBufferSource(body, allowString, hookName) {
|
||||||
*/
|
*/
|
||||||
function stringify(body) {
|
function stringify(body) {
|
||||||
if (typeof body === 'string') { return body; }
|
if (typeof body === 'string') { return body; }
|
||||||
assertBufferSource(body, false, 'transformSource');
|
assertBufferSource(body, false, 'load');
|
||||||
const { TextDecoder } = require('internal/encoding');
|
const { TextDecoder } = require('internal/encoding');
|
||||||
DECODER = DECODER === null ? new TextDecoder() : DECODER;
|
DECODER = DECODER === null ? new TextDecoder() : DECODER;
|
||||||
return DECODER.decode(body);
|
return DECODER.decode(body);
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,11 @@ await assert.rejects(
|
||||||
{ code: 'ERR_INVALID_RETURN_PROPERTY_VALUE' },
|
{ code: 'ERR_INVALID_RETURN_PROPERTY_VALUE' },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await assert.rejects(import('esmHook/commonJsNullSource.mjs'), {
|
||||||
|
code: 'ERR_INVALID_RETURN_PROPERTY_VALUE',
|
||||||
|
message: /"source".*'load'.*got type bigint/,
|
||||||
|
});
|
||||||
|
|
||||||
await import('../fixtures/es-module-loaders/js-as-esm.js')
|
await import('../fixtures/es-module-loaders/js-as-esm.js')
|
||||||
.then((parsedModule) => {
|
.then((parsedModule) => {
|
||||||
assert.strictEqual(typeof parsedModule, 'object');
|
assert.strictEqual(typeof parsedModule, 'object');
|
||||||
|
|
|
||||||
|
|
@ -97,5 +97,13 @@ export function load(url, context, next) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (url.endsWith('esmHook/commonJsNullSource.mjs')) {
|
||||||
|
return {
|
||||||
|
format: 'commonjs',
|
||||||
|
shortCircuit: true,
|
||||||
|
source: 1n,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return next(url);
|
return next(url);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user