Skip to content

Commit 2e19f7f

Browse files
committed
module: reduce url invocations in esm/load.js
nodejs/node#48337
1 parent 81ce588 commit 2e19f7f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

patches/node/fix_lazyload_fs_in_esm_loaders_to_apply_asar_patches.patch

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Subject: fix: lazyload fs in esm loaders to apply asar patches
66
Changes { foo } from fs to just "fs.foo" so that our patching of fs is applied to esm loaders
77

88
diff --git a/lib/internal/modules/esm/load.js b/lib/internal/modules/esm/load.js
9-
index d64d4452a50bc4469b2d2fcc3251b3df31cda6ec..8d8f1b24fb68cce2b37e43f92aac200b4ee73cea 100644
9+
index d8a072cf6af3b0d3a47ee69be04b26875683d261..89932f2572d09dd3383a82ccac060afbc1329071 100644
1010
--- a/lib/internal/modules/esm/load.js
1111
+++ b/lib/internal/modules/esm/load.js
1212
@@ -20,7 +20,7 @@ const experimentalNetworkImports =
@@ -18,14 +18,14 @@ index d64d4452a50bc4469b2d2fcc3251b3df31cda6ec..8d8f1b24fb68cce2b37e43f92aac200b
1818
const { URL } = require('internal/url');
1919
const {
2020
ERR_INVALID_URL,
21-
@@ -34,7 +34,7 @@ async function getSource(url, context) {
22-
let responseURL = url;
21+
@@ -39,7 +39,7 @@ async function getSource(url, context) {
22+
let responseURL = href;
2323
let source;
24-
if (parsed.protocol === 'file:') {
25-
- source = await readFileAsync(parsed);
24+
if (protocol === 'file:') {
25+
- source = await readFileAsync(url);
2626
+ source = await fs.promises.readFile(parsed);
27-
} else if (parsed.protocol === 'data:') {
28-
const match = RegExpPrototypeExec(DATA_URL_PATTERN, parsed.pathname);
27+
} else if (protocol === 'data:') {
28+
const match = RegExpPrototypeExec(DATA_URL_PATTERN, url.pathname);
2929
if (!match) {
3030
diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js
3131
index ce2d851da2577e6e99980eb75337f629b38fddbf..fed26d25b59d66ab6e5160e2e13c8eea0cb44f8d 100644

0 commit comments

Comments
 (0)