For FB, prefer internal build over global build
Summary: This commit makes it so when running the internal version of Flipper, we always prefer the internal build of React DevTools as opposed to a global install of DevTools. Note that users may still change the version the use and select the global version. Externally, i.e. for the OSS build, users will still have the option to always prefer the global build and toggle between it. The motivation for this is to let us ensure that employees are using the latest version of React DevTools and in order to obtain accurate logs of internal usage of DevTools Reviewed By: mweststrate Differential Revision: D33167394 fbshipit-source-id: ee75eedc3a488e223189bbfa6288408bb84824e3
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8f40949bb0
commit
c42c54f69d
@@ -100,16 +100,26 @@ export function devicePlugin(client: DevicePluginClient) {
|
||||
return required.default ?? required;
|
||||
}
|
||||
|
||||
function getInitialDevToolsInstance(): DevToolsInstance {
|
||||
// Load right library
|
||||
if (useGlobalDevTools.get()) {
|
||||
return {
|
||||
type: 'global',
|
||||
module: getGlobalDevToolsModule(),
|
||||
};
|
||||
async function maybeGetInitialGlobalDevTools(): Promise<DevToolsInstance> {
|
||||
const path = await findGlobalDevTools();
|
||||
let instance = devToolsInstance;
|
||||
if (path) {
|
||||
globalDevToolsPath.set(path + '/standalone');
|
||||
console.log('Found global React DevTools: ', path);
|
||||
// load global devtools instance if the flag is set and
|
||||
// we're running a non-FB version of Flipper
|
||||
if (useGlobalDevTools.get() && !client.isFB) {
|
||||
selectedDevToolsInstanceType.set('global');
|
||||
|
||||
instance = {
|
||||
type: 'global',
|
||||
module: getGlobalDevToolsModule(),
|
||||
};
|
||||
}
|
||||
} else {
|
||||
return getDefaultDevToolsInstance();
|
||||
useGlobalDevTools.set(false); // disable in case it was enabled
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
function getDefaultDevToolsInstance(): DevToolsInstance {
|
||||
@@ -341,16 +351,7 @@ export function devicePlugin(client: DevicePluginClient) {
|
||||
}
|
||||
|
||||
client.onReady(async () => {
|
||||
const path = await findGlobalDevTools();
|
||||
if (path) {
|
||||
globalDevToolsPath.set(path + '/standalone');
|
||||
selectedDevToolsInstanceType.set('global');
|
||||
console.log('Found global React DevTools: ', path);
|
||||
// load it, if the flag is set
|
||||
devToolsInstance = getInitialDevToolsInstance();
|
||||
} else {
|
||||
useGlobalDevTools.set(false); // disable in case it was enabled
|
||||
}
|
||||
devToolsInstance = await maybeGetInitialGlobalDevTools();
|
||||
});
|
||||
|
||||
client.onDestroy(() => {
|
||||
|
||||
Reference in New Issue
Block a user