Skip to content

Commit 7928388

Browse files
committed
esm: fallback to readFileSync when source is nullish
nodejs/node#50825
1 parent ef46db8 commit 7928388

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

patches/node/fix_lazyload_fs_in_esm_loaders_to_apply_asar_patches.patch

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ index 2d077cc182b40e0bdce2d71d0471e96e6d30222a..34fd6613fa24d628fc026ac11e5be721
6060
});
6161
const { search, hash } = resolved;
6262
diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
63-
index bda102b266b17936efc453d039213517c4ef921c..dbbe37474c70addfbf8cf805c29732dcd38c74f6 100644
63+
index e5fea28126b1b810cd3e1e5a13c0fdc97b6b71f5..cea066d1073a31573e134d584f1991e7a06b1036 100644
6464
--- a/lib/internal/modules/esm/translators.js
6565
+++ b/lib/internal/modules/esm/translators.js
66-
@@ -32,7 +32,7 @@ function lazyTypes() {
67-
66+
@@ -33,7 +33,7 @@ function lazyTypes() {
6867
const { containsModuleSyntax } = internalBinding('contextify');
68+
const { BuiltinModule } = require('internal/bootstrap/realm');
6969
const assert = require('internal/assert');
7070
-const { readFileSync } = require('fs');
7171
+const fs = require('fs');
7272
const { dirname, extname, isAbsolute } = require('path');
7373
const {
7474
loadBuiltinModule,
75-
@@ -355,7 +355,7 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
75+
@@ -366,7 +366,7 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
7676

7777
try {
7878
// We still need to read the FS to detect the exports.
@@ -81,7 +81,7 @@ index bda102b266b17936efc453d039213517c4ef921c..dbbe37474c70addfbf8cf805c29732dc
8181
} catch {
8282
// Continue regardless of error.
8383
}
84-
@@ -424,7 +424,7 @@ function cjsPreparseModuleExports(filename, source) {
84+
@@ -435,7 +435,7 @@ function cjsPreparseModuleExports(filename, source) {
8585
isAbsolute(resolved)) {
8686
// TODO: this should be calling the `load` hook chain to get the source
8787
// (and fallback to reading the FS only if the source is nullish).
@@ -90,3 +90,4 @@ index bda102b266b17936efc453d039213517c4ef921c..dbbe37474c70addfbf8cf805c29732dc
9090
const { exportNames: reexportNames } = cjsPreparseModuleExports(resolved, source);
9191
for (const name of reexportNames) {
9292
exportNames.add(name);
93+

0 commit comments

Comments
 (0)