Skip to content

Commit

Permalink
module: reduce url invocations in esm/load.js
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Sep 20, 2023
1 parent d26a7dd commit f81d844
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Subject: fix: lazyload fs in esm loaders to apply asar patches
Changes { foo } from fs to just "fs.foo" so that our patching of fs is applied to esm loaders

diff --git a/lib/internal/modules/esm/load.js b/lib/internal/modules/esm/load.js
index d64d4452a50bc4469b2d2fcc3251b3df31cda6ec..8d8f1b24fb68cce2b37e43f92aac200b4ee73cea 100644
index d8a072cf6af3b0d3a47ee69be04b26875683d261..7991703df940634c62d798210b5e7b94412f9bde 100644
--- a/lib/internal/modules/esm/load.js
+++ b/lib/internal/modules/esm/load.js
@@ -20,7 +20,7 @@ const experimentalNetworkImports =
Expand All @@ -18,14 +18,14 @@ index d64d4452a50bc4469b2d2fcc3251b3df31cda6ec..8d8f1b24fb68cce2b37e43f92aac200b
const { URL } = require('internal/url');
const {
ERR_INVALID_URL,
@@ -34,7 +34,7 @@ async function getSource(url, context) {
let responseURL = url;
@@ -39,7 +39,7 @@ async function getSource(url, context) {
let responseURL = href;
let source;
if (parsed.protocol === 'file:') {
- source = await readFileAsync(parsed);
+ source = await fs.promises.readFile(parsed);
} else if (parsed.protocol === 'data:') {
const match = RegExpPrototypeExec(DATA_URL_PATTERN, parsed.pathname);
if (protocol === 'file:') {
- source = await readFileAsync(url);
+ source = await fs.promises.readFile(url);
} else if (protocol === 'data:') {
const match = RegExpPrototypeExec(DATA_URL_PATTERN, url.pathname);
if (!match) {
diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js
index ce2d851da2577e6e99980eb75337f629b38fddbf..fed26d25b59d66ab6e5160e2e13c8eea0cb44f8d 100644
Expand Down

0 comments on commit f81d844

Please sign in to comment.