Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c2b6edf

Browse filesBrowse files
bmacnaughtonRafaelGSS
authored andcommitted
esm: fix hook name in error message
PR-URL: #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>
1 parent 9950103 commit c2b6edf
Copy full SHA for c2b6edf

File tree

Expand file treeCollapse file tree

4 files changed

+16
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+16
-3
lines changed
Open diff view settings
Collapse file

‎lib/internal/errors.js‎

Copy file name to clipboardExpand all lines: lib/internal/errors.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,11 +1475,11 @@ E('ERR_INVALID_REPL_EVAL_CONFIG',
14751475
E('ERR_INVALID_REPL_INPUT', '%s', TypeError);
14761476
E('ERR_INVALID_RETURN_PROPERTY', (input, name, prop, value) => {
14771477
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)}.`;
14791479
}, TypeError);
14801480
E('ERR_INVALID_RETURN_PROPERTY_VALUE', (input, name, prop, value) => {
14811481
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)}.`;
14831483
}, TypeError);
14841484
E('ERR_INVALID_RETURN_VALUE', (input, name, value) => {
14851485
const type = determineSpecificType(value);
Collapse file

‎lib/internal/modules/esm/translators.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/esm/translators.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function assertBufferSource(body, allowString, hookName) {
128128
*/
129129
function stringify(body) {
130130
if (typeof body === 'string') { return body; }
131-
assertBufferSource(body, false, 'transformSource');
131+
assertBufferSource(body, false, 'load');
132132
const { TextDecoder } = require('internal/encoding');
133133
DECODER = DECODER === null ? new TextDecoder() : DECODER;
134134
return DECODER.decode(body);
Collapse file

‎test/es-module/test-esm-loader.mjs‎

Copy file name to clipboardExpand all lines: test/es-module/test-esm-loader.mjs
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ await assert.rejects(
4343
{ code: 'ERR_INVALID_RETURN_PROPERTY_VALUE' },
4444
);
4545

46+
await assert.rejects(import('esmHook/commonJsNullSource.mjs'), {
47+
code: 'ERR_INVALID_RETURN_PROPERTY_VALUE',
48+
message: /"source".*'load'.*got type bigint/,
49+
});
50+
4651
await import('../fixtures/es-module-loaders/js-as-esm.js')
4752
.then((parsedModule) => {
4853
assert.strictEqual(typeof parsedModule, 'object');
Collapse file

‎test/fixtures/es-module-loaders/hooks-custom.mjs‎

Copy file name to clipboardExpand all lines: test/fixtures/es-module-loaders/hooks-custom.mjs
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,13 @@ export function load(url, context, next) {
9797
};
9898
}
9999

100+
if (url.endsWith('esmHook/commonJsNullSource.mjs')) {
101+
return {
102+
format: 'commonjs',
103+
shortCircuit: true,
104+
source: 1n,
105+
};
106+
}
107+
100108
return next(url);
101109
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.