@@ -6,12 +6,12 @@ Subject: fix: lazyload fs in esm loaders to apply asar patches
66Changes { foo } from fs to just "fs.foo" so that our patching of fs is applied to esm loaders
77
88diff --git a/lib/internal/modules/esm/load.js b/lib/internal/modules/esm/load.js
9- index 14d5236d0ead946acf9a2f63bf979e7193bfbf56..74136abfb9aae1fc8ab746908be752056b6d7c5a 100644
9+ index f108b567a910805ff86f0baf75fa1a6102ad28d6..8406e8ca319533d6186c5d457e951b7a845b6b72 100644
1010--- a/lib/internal/modules/esm/load.js
1111+++ b/lib/internal/modules/esm/load.js
1212@@ -10,7 +10,7 @@ const { kEmptyObject } = require('internal/util');
1313 const { defaultGetFormat } = require('internal/modules/esm/get_format');
14- const { validateAssertions } = require('internal/modules/esm/assert');
14+ const { validateAttributes, emitImportAssertionWarning } = require('internal/modules/esm/assert');
1515 const { getOptionValue } = require('internal/options');
1616- const { readFileSync } = require('fs');
1717+ const fs = require('fs');
@@ -60,28 +60,19 @@ index acfcc1f1f92548117ded857fa8d4dd140e07ab2b..ce8092b96aee8d09ff382110db4be62d
6060 });
6161 const { search, hash } = resolved;
6262diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
63- index 178f362b2869173d51b2e97a8d35a16ab4ed4962..4c3a0d8c484a402fe419a0bd45c7e2b1d717cb4a 100644
63+ index bda102b266b17936efc453d039213517c4ef921c..dbbe37474c70addfbf8cf805c29732dcd38c74f6 100644
6464--- a/lib/internal/modules/esm/translators.js
6565+++ b/lib/internal/modules/esm/translators.js
66- @@ -25,7 +25,7 @@ function lazyTypes() {
67- }
66+ @@ -32,7 +32,7 @@ function lazyTypes() {
6867
68+ const { containsModuleSyntax } = internalBinding('contextify');
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 {
74- hasEsmSyntax,
75- @@ -132,7 +132,7 @@ translators.set('module', async function moduleStrategy(url, source, isMain) {
76- */
77- function enrichCJSError(err, content, filename) {
78- if (err != null && ObjectGetPrototypeOf(err) === SyntaxErrorPrototype &&
79- - hasEsmSyntax(content || readFileSync(filename, 'utf-8'))) {
80- + hasEsmSyntax(content || fs.readFileSync(filename, 'utf-8'))) {
81- // Emit the warning synchronously because we are in the middle of handling
82- // a SyntaxError that will throw and likely terminate the process before an
83- // asynchronous warning would be emitted.
84- @@ -294,7 +294,7 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
74+ loadBuiltinModule,
75+ @@ -355,7 +355,7 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
8576
8677 try {
8778 // We still need to read the FS to detect the exports.
@@ -90,12 +81,12 @@ index 178f362b2869173d51b2e97a8d35a16ab4ed4962..4c3a0d8c484a402fe419a0bd45c7e2b1
9081 } catch {
9182 // Continue regardless of error.
9283 }
93- @@ -357 ,7 +357 ,7 @@ function cjsPreparseModuleExports(filename, source) {
84+ @@ -424 ,7 +424 ,7 @@ function cjsPreparseModuleExports(filename, source) {
9485 isAbsolute(resolved)) {
9586 // TODO: this should be calling the `load` hook chain to get the source
9687 // (and fallback to reading the FS only if the source is nullish).
9788- const source = readFileSync(resolved, 'utf-8');
9889+ const source = fs.readFileSync(resolved, 'utf-8');
9990 const { exportNames: reexportNames } = cjsPreparseModuleExports(resolved, source);
100- for (const name of reexportNames)
91+ for (const name of reexportNames) {
10192 exportNames.add(name);
0 commit comments