Patch metro to avoid erasing "process" global var

Summary:
Patch for "metro" to avoid erasing of "process" global var during bundling.

Also removed "process" babel transform for main Electron process which was also made to workaround the same issue with "process" being erased.

Reviewed By: mweststrate

Differential Revision: D22389153

fbshipit-source-id: 569882e20534eedfca45509b8efe0186d335c681
This commit is contained in:
Anton Nikolaev
2020-07-06 03:08:11 -07:00
committed by Facebook GitHub Bot
parent 7c3d264803
commit a2e77f5da0
4 changed files with 14 additions and 104 deletions

View File

@@ -1,3 +1,16 @@
diff --git a/node_modules/metro/src/lib/getPreludeCode.js b/node_modules/metro/src/lib/getPreludeCode.js
index 57e008e..b645266 100644
--- a/node_modules/metro/src/lib/getPreludeCode.js
+++ b/node_modules/metro/src/lib/getPreludeCode.js
@@ -42,7 +42,7 @@ function getPreludeCode(_ref) {
"__BUNDLE_START_TIME__=this.nativePerformanceNow?nativePerformanceNow():Date.now()",
`__DEV__=${String(isDev)}`
].concat(_toConsumableArray(formatExtraVars(extraVars)), [
- "process=this.process||{}"
+ "process=process||this.process||global.process||{}"
]);
return `var ${vars.join(",")};${processEnv(
isDev ? "development" : "production"
diff --git a/node_modules/metro/src/lib/polyfills/require.js b/node_modules/metro/src/lib/polyfills/require.js
index 8c04756..d773811 100644
--- a/node_modules/metro/src/lib/polyfills/require.js