diff --git a/Libraries/Core/setUpReactRefresh.js b/Libraries/Core/setUpReactRefresh.js index 4ee10acf086..ccc67ca2239 100644 --- a/Libraries/Core/setUpReactRefresh.js +++ b/Libraries/Core/setUpReactRefresh.js @@ -45,5 +45,7 @@ if (__DEV__) { }, }; - (require: any).Refresh = Refresh; + // The metro require polyfill can not have dependencies (applies for all polyfills). + // Expose `Refresh` by assigning it to global to make it available in the polyfill. + global[(global.__METRO_GLOBAL_PREFIX__ || '') + '__ReactRefresh'] = Refresh; } diff --git a/Libraries/Performance/Systrace.js b/Libraries/Performance/Systrace.js index 048c3d40427..6089016521b 100644 --- a/Libraries/Performance/Systrace.js +++ b/Libraries/Performance/Systrace.js @@ -209,11 +209,9 @@ const Systrace = { }; if (__DEV__) { - // This is needed, because require callis in polyfills are not processed as - // other files. Therefore, calls to `require('moduleId')` are not replaced - // with numeric IDs - // TODO(davidaurelio) Scan polyfills for dependencies, too (t9759686) - (require: $FlowFixMe).Systrace = Systrace; + // The metro require polyfill can not have dependencies (true for all polyfills). + // Ensure that `Systrace` is available in polyfill by exposing it globally. + global[(global.__METRO_GLOBAL_PREFIX__ || '') + '__SYSTRACE'] = Systrace; } module.exports = Systrace;