Skip to content

Commit f27c0f6

Browse files
!fixup: remove obsolete getSource in favour of getSourceSync
1 parent b7bc7fb commit f27c0f6

File tree

1 file changed

+2
-26
lines changed

1 file changed

+2
-26
lines changed

lib/internal/modules/esm/load.js

+2-26
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,7 @@ const {
2626

2727
/**
2828
* @param {URL} url URL to the module
29-
* @param {ESModuleContext} context used to decorate error messages
30-
* @returns {Promise<{ responseURL: string, source: string | BufferView }>}
31-
*/
32-
function getSource(url, context) {
33-
const { protocol, href } = url;
34-
const responseURL = href;
35-
let source;
36-
if (protocol === 'file:') {
37-
source = readFileSync(url);
38-
} else if (protocol === 'data:') {
39-
const result = dataURLProcessor(url);
40-
if (result === 'failure') {
41-
throw new ERR_INVALID_URL(responseURL, null);
42-
}
43-
source = BufferFrom(result.body);
44-
} else {
45-
const supportedSchemes = ['file', 'data'];
46-
throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(url, supportedSchemes);
47-
}
48-
return { __proto__: null, responseURL, source };
49-
}
50-
51-
/**
52-
* @param {URL} url URL to the module
53-
* @param {ESModuleContext} context used to decorate error messages
29+
* @param {LoadContext} context used to decorate error messages
5430
* @returns {{ responseURL: string, source: string | BufferView }}
5531
*/
5632
function getSourceSync(url, context) {
@@ -109,7 +85,7 @@ function defaultLoad(url, context = kEmptyObject) {
10985
source = null;
11086
} else if (format !== 'commonjs') {
11187
if (source == null) {
112-
({ responseURL, source } = getSource(urlInstance, context));
88+
({ responseURL, source } = getSourceSync(urlInstance, context));
11389
context = { __proto__: context, source };
11490
}
11591

0 commit comments

Comments
 (0)