GeezerVison is showing github.com — esm: fix hook name in error message · nodejs/node@c2b6edf
File treeExpand file treeCollapse file tree Open diff view settings fixtures/es-module-loaders
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/errors.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1475,11 +1475,11 @@ E('ERR_INVALID_REPL_EVAL_CONFIG', | 1475 | 1475 | E('ERR_INVALID_REPL_INPUT', '%s', TypeError); | 1476 | 1476 | E('ERR_INVALID_RETURN_PROPERTY', (input, name, prop, value) => { | 1477 | 1477 | return `Expected a valid ${input} to be returned for the "${prop}" from the` + | 1478 | | - ` "${name}" function but got ${determineSpecificType(value)}.`; | | 1478 | + ` "${name}" hook but got ${determineSpecificType(value)}.`; | 1479 | 1479 | }, TypeError); | 1480 | 1480 | E('ERR_INVALID_RETURN_PROPERTY_VALUE', (input, name, prop, value) => { | 1481 | 1481 | return `Expected ${input} to be returned for the "${prop}" from the` + | 1482 | | - ` "${name}" function but got ${determineSpecificType(value)}.`; | | 1482 | + ` "${name}" hook but got ${determineSpecificType(value)}.`; | 1483 | 1483 | }, TypeError); | 1484 | 1484 | E('ERR_INVALID_RETURN_VALUE', (input, name, value) => { | 1485 | 1485 | const type = determineSpecificType(value); | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/modules/esm/translators.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -128,7 +128,7 @@ function assertBufferSource(body, allowString, hookName) { | 128 | 128 | */ | 129 | 129 | function stringify(body) { | 130 | 130 | if (typeof body === 'string') { return body; } | 131 | | - assertBufferSource(body, false, 'transformSource'); | | 131 | + assertBufferSource(body, false, 'load'); | 132 | 132 | const { TextDecoder } = require('internal/encoding'); | 133 | 133 | DECODER = DECODER === null ? new TextDecoder() : DECODER; | 134 | 134 | return DECODER.decode(body); | |
Collapse file Copy file name to clipboardExpand all lines: test/es-module/test-esm-loader.mjs +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -43,6 +43,11 @@ await assert.rejects( | 43 | 43 | { code: 'ERR_INVALID_RETURN_PROPERTY_VALUE' }, | 44 | 44 | ); | 45 | 45 |
| | 46 | +await assert.rejects(import('esmHook/commonJsNullSource.mjs'), { | | 47 | + code: 'ERR_INVALID_RETURN_PROPERTY_VALUE', | | 48 | + message: /"source".*'load'.*got type bigint/, | | 49 | +}); | | 50 | + | 46 | 51 | await import('../fixtures/es-module-loaders/js-as-esm.js') | 47 | 52 | .then((parsedModule) => { | 48 | 53 | assert.strictEqual(typeof parsedModule, 'object'); | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/es-module-loaders/hooks-custom.mjs +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -97,5 +97,13 @@ export function load(url, context, next) { | 97 | 97 | }; | 98 | 98 | } | 99 | 99 |
| | 100 | + if (url.endsWith('esmHook/commonJsNullSource.mjs')) { | | 101 | + return { | | 102 | + format: 'commonjs', | | 103 | + shortCircuit: true, | | 104 | + source: 1n, | | 105 | + }; | | 106 | + } | | 107 | + | 100 | 108 | return next(url); | 101 | 109 | } |
|