Skip to content

Commit a548fe4

Browse files
committed
esm: align sync and async load implementations
nodejs/node#49152
1 parent 8195995 commit a548fe4

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

patches/node/fix_lazyload_fs_in_esm_loaders_to_apply_asar_patches.patch

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,37 @@ 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 ac24cf305bd5995ad13b37ee36f9e1fe3589c5d7..22248b753c14960122f1d6b9bfe6b89fdb8d2010 100644
9+
index 605e812d515fc467001e4ab88fc15b4af3fd4aa2..463e76cb1abc0c2fdddba4db2ca2e00f7c591e12 100644
1010
--- a/lib/internal/modules/esm/load.js
1111
+++ b/lib/internal/modules/esm/load.js
12-
@@ -10,7 +10,7 @@ const { kEmptyObject } = require('internal/util');
12+
@@ -8,7 +8,7 @@ const { kEmptyObject } = require('internal/util');
1313
const { defaultGetFormat } = require('internal/modules/esm/get_format');
1414
const { validateAttributes, emitImportAssertionWarning } = require('internal/modules/esm/assert');
1515
const { getOptionValue } = require('internal/options');
1616
-const { readFileSync } = require('fs');
1717
+const fs = require('fs');
1818

19-
// Do not eagerly grab .manifest, it may be in TDZ
20-
const policy = getOptionValue('--experimental-policy') ?
21-
@@ -42,8 +42,7 @@ async function getSource(url, context) {
22-
let responseURL = href;
19+
const defaultType =
20+
getOptionValue('--experimental-default-type');
21+
@@ -40,8 +40,7 @@ async function getSource(url, context) {
22+
const responseURL = href;
2323
let source;
2424
if (protocol === 'file:') {
2525
- const { readFile: readFileAsync } = require('internal/fs/promises').exports;
2626
- source = await readFileAsync(url);
2727
+ source = await fs.promises.readFile(url);
2828
} else if (protocol === 'data:') {
29-
const match = RegExpPrototypeExec(DATA_URL_PATTERN, url.pathname);
30-
if (!match) {
31-
@@ -82,7 +81,7 @@ function getSourceSync(url, context) {
29+
const result = dataURLProcessor(url);
30+
if (result === 'failure') {
31+
@@ -65,7 +64,7 @@ function getSourceSync(url, context) {
3232
const responseURL = href;
3333
let source;
3434
if (protocol === 'file:') {
3535
- source = readFileSync(url);
3636
+ source = fs.readFileSync(url);
3737
} else if (protocol === 'data:') {
38-
const match = RegExpPrototypeExec(DATA_URL_PATTERN, url.pathname);
39-
if (!match) {
38+
const result = dataURLProcessor(url);
39+
if (result === 'failure') {
4040
diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js
4141
index 52cdb7d5e14a18ed7b1b65e429729cf47dce3f98..69f73f829706deddc4f328b78af9d58434af647d 100644
4242
--- a/lib/internal/modules/esm/resolve.js

0 commit comments

Comments
 (0)