GeezerVison is showing github.com — esm: fix hook name in error message · nodejs/node@84b0ead
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 |
|---|
@@ -1354,11 +1354,11 @@ E('ERR_INVALID_REPL_EVAL_CONFIG', | 1354 | 1354 | E('ERR_INVALID_REPL_INPUT', '%s', TypeError); | 1355 | 1355 | E('ERR_INVALID_RETURN_PROPERTY', (input, name, prop, value) => { | 1356 | 1356 | return `Expected a valid ${input} to be returned for the "${prop}" from the` + | 1357 | | - ` "${name}" function but got ${determineSpecificType(value)}.`; | | 1357 | + ` "${name}" hook but got ${determineSpecificType(value)}.`; | 1358 | 1358 | }, TypeError); | 1359 | 1359 | E('ERR_INVALID_RETURN_PROPERTY_VALUE', (input, name, prop, value) => { | 1360 | 1360 | return `Expected ${input} to be returned for the "${prop}" from the` + | 1361 | | - ` "${name}" function but got ${determineSpecificType(value)}.`; | | 1361 | + ` "${name}" hook but got ${determineSpecificType(value)}.`; | 1362 | 1362 | }, TypeError); | 1363 | 1363 | E('ERR_INVALID_RETURN_VALUE', (input, name, value) => { | 1364 | 1364 | 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 |
|---|
@@ -113,7 +113,7 @@ function assertBufferSource(body, allowString, hookName) { | 113 | 113 | */ | 114 | 114 | function stringify(body) { | 115 | 115 | if (typeof body === 'string') { return body; } | 116 | | - assertBufferSource(body, false, 'transformSource'); | | 116 | + assertBufferSource(body, false, 'load'); | 117 | 117 | const { TextDecoder } = require('internal/encoding'); | 118 | 118 | DECODER = DECODER === null ? new TextDecoder() : DECODER; | 119 | 119 | 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 | } |
|