Remove remaining Electron imports from product code: paths & env
Summary: This diff removes most remaining Electron imports, by storing env and path constants on the RenderHost. As nice side effect those paths are all cached now as well. To make sure RenderHost is initialised before Flipper itself, forced loading Flipper through a require. Otherwise the setup is super sensitive to circular import statements, since a lot of module initialisation code depends on those paths / env vars. Reviewed By: nikoant Differential Revision: D31992230 fbshipit-source-id: 91beb430902272aaf4b051b35cdf12d2fc993347
This commit is contained in:
committed by
Facebook GitHub Bot
parent
dba09542f9
commit
2e7015388c
@@ -10,8 +10,6 @@
|
||||
import React from 'react';
|
||||
import {styled, colors, FlexColumn} from 'flipper';
|
||||
|
||||
import electron from 'electron';
|
||||
|
||||
const devToolsNodeId = (url: string) =>
|
||||
`hermes-chromedevtools-out-of-react-node-${url.replace(/\W+/g, '-')}`;
|
||||
|
||||
@@ -28,10 +26,16 @@ function createDevToolsNode(
|
||||
return existing;
|
||||
}
|
||||
|
||||
// It is necessary to activate chrome devtools in electron
|
||||
electron.remote.getCurrentWindow().webContents.toggleDevTools();
|
||||
electron.remote.getCurrentWindow().webContents.closeDevTools();
|
||||
|
||||
// It is necessary to deactivate chrome devtools in electron
|
||||
try {
|
||||
const electron = require('electron');
|
||||
if (electron.default) {
|
||||
electron.default.remote.getCurrentWindow().webContents.toggleDevTools();
|
||||
electron.default.remote.getCurrentWindow().webContents.closeDevTools();
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Failed to close Electron devtools: ', e);
|
||||
}
|
||||
const wrapper = document.createElement('div');
|
||||
wrapper.id = devToolsNodeId(url);
|
||||
wrapper.style.height = '100%';
|
||||
|
||||
Reference in New Issue
Block a user