Skip to content

Commit 3a0882a

Browse files
esm: syncify default path of ModuleLoader.load
1 parent 5a2614f commit 3a0882a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/internal/modules/esm/load.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ const {
2929
* @param {ESModuleContext} context used to decorate error messages
3030
* @returns {Promise<{ responseURL: string, source: string | BufferView }>}
3131
*/
32-
async function getSource(url, context) {
32+
function getSource(url, context) {
3333
const { protocol, href } = url;
3434
const responseURL = href;
3535
let source;
3636
if (protocol === 'file:') {
37-
const { readFile: readFileAsync } = require('internal/fs/promises').exports;
38-
source = await readFileAsync(url);
37+
source = readFileSync(url);
3938
} else if (protocol === 'data:') {
4039
const result = dataURLProcessor(url);
4140
if (result === 'failure') {
@@ -80,7 +79,7 @@ function getSourceSync(url, context) {
8079
* @param {LoadContext} context
8180
* @returns {LoadReturn}
8281
*/
83-
async function defaultLoad(url, context = kEmptyObject) {
82+
function defaultLoad(url, context = kEmptyObject) {
8483
let responseURL = url;
8584
let {
8685
importAttributes,
@@ -110,13 +109,13 @@ async function defaultLoad(url, context = kEmptyObject) {
110109
source = null;
111110
} else if (format !== 'commonjs') {
112111
if (source == null) {
113-
({ responseURL, source } = await getSource(urlInstance, context));
112+
({ responseURL, source } = getSource(urlInstance, context));
114113
context = { __proto__: context, source };
115114
}
116115

117116
if (format == null) {
118117
// Now that we have the source for the module, run `defaultGetFormat` to detect its format.
119-
format = await defaultGetFormat(urlInstance, context);
118+
format = defaultGetFormat(urlInstance, context);
120119

121120
if (format === 'commonjs') {
122121
// For backward compatibility reasons, we need to discard the source in

0 commit comments

Comments
 (0)