function polyfillGlobal<T>(name: string, getValue: () => T): void { defineLazyProperty(global, name, getValue); } // Set up process global.process = global.process || {}; global.process.env = global.process.env || {}; if (!global.process.env.NODE_ENV) { global.process.env.NODE_ENV = __DEV__ ? 'development' : 'production'; } // Setup the Systrace profiling hooks if necessary if (global.__RCTProfileIsProfiling) { const Systrace = require('Systrace'); Systrace.installReactHook(true); Systrace.setEnabled(true); } // Set up console const ExceptionsManager = require('ExceptionsManager'); ExceptionsManager.installConsoleErrorReporter(); // Set up error handler if (!global.__fbDisableExceptionsManager) { const handleError = (e, isFatal) => { try { ExceptionsManager.handleException(e, isFatal); } catch (ee) { console.log('Failed to print error: ', ee.message); throw e; }
enumerable: enumerable !== false, writable: writable !== false, }); } } // Set up process global.process = global.process || {}; global.process.env = global.process.env || {}; if (!global.process.env.NODE_ENV) { global.process.env.NODE_ENV = __DEV__ ? 'development' : 'production'; } // Set up profile const Systrace = require('Systrace'); Systrace.setEnabled(global.__RCTProfileIsProfiling || false); if (__DEV__) { if (global.performance === undefined) { global.performance = Systrace.getUserTimingPolyfill(); } } // Set up console const ExceptionsManager = require('ExceptionsManager'); ExceptionsManager.installConsoleErrorReporter(); // TODO: Move these around to solve the cycle in a cleaner way const BatchedBridge = require('BatchedBridge'); BatchedBridge.registerLazyCallableModule('Systrace', () => require('Systrace')); BatchedBridge.registerLazyCallableModule('JSTimers', () => require('JSTimers')); BatchedBridge.registerLazyCallableModule('HeapCapture', () => require('HeapCapture'));
function setUpProfile(): void { const Systrace = require('Systrace'); Systrace.setEnabled(global.__RCTProfileIsProfiling || false); }