From aeef7b511ec46da635b071c843a89485a9e6eec7 Mon Sep 17 00:00:00 2001 From: Emily Janzer Date: Thu, 13 Jun 2019 08:48:15 -0700 Subject: [PATCH] Disable dev tools in bridgeless mode Summary: Developer tools have a lot of dependencies on the bridge, so for now I'm just disabling them in bridgeless mode entirely by guarding everything in `setUpDeveloperTools` with the `RN$Bridgeless` flag. Also consolidating some of the stuff Dan added to `InitializeCore` for hot reloading in here. Reviewed By: zackargyle Differential Revision: D15797924 fbshipit-source-id: 360ea81a2844e49f7281eed259fc16a541148ac2 --- Libraries/Core/InitializeCore.js | 9 ----- Libraries/Core/setUpDeveloperTools.js | 50 +++++++++++++++++---------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/Libraries/Core/InitializeCore.js b/Libraries/Core/InitializeCore.js index d1807071d03eb3..8b9a6a490739d1 100644 --- a/Libraries/Core/InitializeCore.js +++ b/Libraries/Core/InitializeCore.js @@ -41,15 +41,6 @@ require('./setUpSegmentFetcher'); if (__DEV__) { require('./checkNativeVersion'); require('./setUpDeveloperTools'); - - // This is used by the require.js polyfill for hot reloading. - // TODO(t9759686) Scan polyfills for dependencies, too - const reload = require('../NativeModules/specs/NativeDevSettings').default - .reload; - if (typeof reload !== 'function') { - throw new Error('Could not find the reload() implementation.'); - } - (require: any).reload = reload; } const GlobalPerformanceLogger = require('../Utilities/GlobalPerformanceLogger'); diff --git a/Libraries/Core/setUpDeveloperTools.js b/Libraries/Core/setUpDeveloperTools.js index 43213cb94bb78d..66037c1553ef4f 100644 --- a/Libraries/Core/setUpDeveloperTools.js +++ b/Libraries/Core/setUpDeveloperTools.js @@ -16,27 +16,39 @@ import Platform from '../Utilities/Platform'; * You can use this module directly, or just require InitializeCore. */ if (__DEV__) { - if (!global.__RCTProfileIsProfiling) { - // not when debugging in chrome - // TODO(t12832058) This check is broken - if (!window.document) { - require('./Devtools/setupDevtools'); + // TODO (T45803484) Enable devtools for bridgeless RN + if (!global.RN$Bridgeless) { + if (!global.__RCTProfileIsProfiling) { + // not when debugging in chrome + // TODO(t12832058) This check is broken + if (!window.document) { + require('./Devtools/setupDevtools'); + } + + // Set up inspector + const JSInspector = require('../JSInspector/JSInspector'); + JSInspector.registerAgent(require('../JSInspector/NetworkAgent')); } - // Set up inspector - const JSInspector = require('../JSInspector/JSInspector'); - JSInspector.registerAgent(require('../JSInspector/NetworkAgent')); - } + if (!Platform.isTesting) { + const logToConsole = require('./Devtools/logToConsole'); + ['log', 'warn', 'info', 'trace'].forEach(level => { + const originalFunction = console[level]; + // $FlowFixMe Overwrite console methods + console[level] = function(...args) { + logToConsole(level, args); + originalFunction.apply(console, args); + }; + }); + } - if (!Platform.isTesting) { - const logToConsole = require('./Devtools/logToConsole'); - ['log', 'warn', 'info', 'trace'].forEach(level => { - const originalFunction = console[level]; - // $FlowFixMe Overwrite console methods - console[level] = function(...args) { - logToConsole(level, args); - originalFunction.apply(console, args); - }; - }); + // This is used by the require.js polyfill for hot reloading. + // TODO(t9759686) Scan polyfills for dependencies, too + const reload = require('../NativeModules/specs/NativeDevSettings').default + .reload; + if (typeof reload !== 'function') { + throw new Error('Could not find the reload() implementation.'); + } + (require: any).reload = reload; // flowlint-line unclear-type: off } }