GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — esm: fix hook name in error message · nodejs/node@84b0ead

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal
    • errors.js
    • modules/esm
      • translators.js
  • test
    • es-module
      • test-esm-loader.mjs
    • fixtures/es-module-loaders
      • hooks-custom.mjs
Expand file treeCollapse file tree
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
@@ -1354,11 +1354,11 @@ E('ERR_INVALID_REPL_EVAL_CONFIG',
13541354
E('ERR_INVALID_REPL_INPUT', '%s', TypeError);
13551355
E('ERR_INVALID_RETURN_PROPERTY', (input, name, prop, value) => {
13561356
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)}.`;
13581358
}, TypeError);
13591359
E('ERR_INVALID_RETURN_PROPERTY_VALUE', (input, name, prop, value) => {
13601360
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)}.`;
13621362
}, TypeError);
13631363
E('ERR_INVALID_RETURN_VALUE', (input, name, value) => {
13641364
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
@@ -113,7 +113,7 @@ function assertBufferSource(body, allowString, hookName) {
113113
*/
114114
function stringify(body) {
115115
if (typeof body === 'string') { return body; }
116-
assertBufferSource(body, false, 'transformSource');
116+
assertBufferSource(body, false, 'load');
117117
const { TextDecoder } = require('internal/encoding');
118118
DECODER = DECODER === null ? new TextDecoder() : DECODER;
119119
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)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.