@@ -26,32 +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- async function getSource ( url , context ) {
33- const { protocol, href } = url ;
34- const responseURL = href ;
35- let source ;
36- if ( protocol === 'file:' ) {
37- const { readFile : readFileAsync } = require ( 'internal/fs/promises' ) . exports ;
38- source = await readFileAsync ( url ) ;
39- } else if ( protocol === 'data:' ) {
40- const result = dataURLProcessor ( url ) ;
41- if ( result === 'failure' ) {
42- throw new ERR_INVALID_URL ( responseURL , null ) ;
43- }
44- source = BufferFrom ( result . body ) ;
45- } else {
46- const supportedSchemes = [ 'file' , 'data' ] ;
47- throw new ERR_UNSUPPORTED_ESM_URL_SCHEME ( url , supportedSchemes ) ;
48- }
49- return { __proto__ : null , responseURL, source } ;
50- }
51-
52- /**
53- * @param {URL } url URL to the module
54- * @param {ESModuleContext } context used to decorate error messages
29+ * @param {LoadContext } context used to decorate error messages
5530 * @returns {{ responseURL: string, source: string | BufferView } }
5631 */
5732function getSourceSync ( url , context ) {
@@ -80,7 +55,7 @@ function getSourceSync(url, context) {
8055 * @param {LoadContext } context
8156 * @returns {LoadReturn }
8257 */
83- async function defaultLoad ( url , context = kEmptyObject ) {
58+ function defaultLoad ( url , context = kEmptyObject ) {
8459 let responseURL = url ;
8560 let {
8661 importAttributes,
@@ -110,13 +85,13 @@ async function defaultLoad(url, context = kEmptyObject) {
11085 source = null ;
11186 } else if ( format !== 'commonjs' ) {
11287 if ( source == null ) {
113- ( { responseURL, source } = await getSource ( urlInstance , context ) ) ;
88+ ( { responseURL, source } = getSourceSync ( urlInstance , context ) ) ;
11489 context = { __proto__ : context , source } ;
11590 }
11691
11792 if ( format == null ) {
11893 // Now that we have the source for the module, run `defaultGetFormat` to detect its format.
119- format = await defaultGetFormat ( urlInstance , context ) ;
94+ format = defaultGetFormat ( urlInstance , context ) ;
12095
12196 if ( format === 'commonjs' ) {
12297 // For backward compatibility reasons, we need to discard the source in
0 commit comments