@@ -30,32 +30,7 @@ const {
30
30
31
31
/**
32
32
* @param {URL } url URL to the module
33
- * @param {ESModuleContext } context used to decorate error messages
34
- * @returns {Promise<{ responseURL: string, source: string | BufferView }> }
35
- */
36
- async function getSource ( url , context ) {
37
- const { protocol, href } = url ;
38
- const responseURL = href ;
39
- let source ;
40
- if ( protocol === 'file:' ) {
41
- const { readFile : readFileAsync } = require ( 'internal/fs/promises' ) . exports ;
42
- source = await readFileAsync ( url ) ;
43
- } else if ( protocol === 'data:' ) {
44
- const result = dataURLProcessor ( url ) ;
45
- if ( result === 'failure' ) {
46
- throw new ERR_INVALID_URL ( responseURL , null ) ;
47
- }
48
- source = BufferFrom ( result . body ) ;
49
- } else {
50
- const supportedSchemes = [ 'file' , 'data' ] ;
51
- throw new ERR_UNSUPPORTED_ESM_URL_SCHEME ( url , supportedSchemes ) ;
52
- }
53
- return { __proto__ : null , responseURL, source } ;
54
- }
55
-
56
- /**
57
- * @param {URL } url URL to the module
58
- * @param {ESModuleContext } context used to decorate error messages
33
+ * @param {LoadContext } context used to decorate error messages
59
34
* @returns {{ responseURL: string, source: string | BufferView } }
60
35
*/
61
36
function getSourceSync ( url , context ) {
@@ -84,7 +59,7 @@ function getSourceSync(url, context) {
84
59
* @param {LoadContext } context
85
60
* @returns {LoadReturn }
86
61
*/
87
- async function defaultLoad ( url , context = kEmptyObject ) {
62
+ function defaultLoad ( url , context = kEmptyObject ) {
88
63
let responseURL = url ;
89
64
let {
90
65
importAttributes,
@@ -111,13 +86,13 @@ async function defaultLoad(url, context = kEmptyObject) {
111
86
format ??= 'builtin' ;
112
87
} else if ( format !== 'commonjs' || defaultType === 'module' ) {
113
88
if ( source == null ) {
114
- ( { responseURL, source } = await getSource ( urlInstance , context ) ) ;
89
+ ( { responseURL, source } = getSourceSync ( urlInstance , context ) ) ;
115
90
context = { __proto__ : context , source } ;
116
91
}
117
92
118
93
if ( format == null ) {
119
94
// Now that we have the source for the module, run `defaultGetFormat` to detect its format.
120
- format = await defaultGetFormat ( urlInstance , context ) ;
95
+ format = defaultGetFormat ( urlInstance , context ) ;
121
96
122
97
if ( format === 'commonjs' ) {
123
98
// For backward compatibility reasons, we need to discard the source in
0 commit comments