Restructure modules to reduce import-time side effects
Summary: `flipper` does a lot of stuff at import time. I copied the `styled` reexport to the UI module, so it's possible to just depend on that. `remote` is another one of those pot holes that can easily ruin your journey if you aren't careful navigating around it. Added some defensive fallbacks here which ultimately allows the lint test to run (and pass) without Electron. Reviewed By: danielbuechele Differential Revision: D10507655 fbshipit-source-id: 6dad5665ba15b5cb73caa4ea46262cf337173eb8
This commit is contained in:
committed by
Facebook Github Bot
parent
2f307b8b4f
commit
c3e4f16188
@@ -17,8 +17,6 @@ import {
|
|||||||
import {remote} from 'electron';
|
import {remote} from 'electron';
|
||||||
|
|
||||||
const plugins = new Map();
|
const plugins = new Map();
|
||||||
// $FlowFixMe process.env not defined in electron API spec
|
|
||||||
const remoteEnv = remote.process.env;
|
|
||||||
|
|
||||||
// expose Flipper and exact globally for dynamically loaded plugins
|
// expose Flipper and exact globally for dynamically loaded plugins
|
||||||
window.React = React;
|
window.React = React;
|
||||||
@@ -33,14 +31,16 @@ const addIfNotAdded = plugin => {
|
|||||||
|
|
||||||
let disabledPlugins = [];
|
let disabledPlugins = [];
|
||||||
try {
|
try {
|
||||||
disabledPlugins = JSON.parse(remoteEnv.CONFIG || '{}').disabledPlugins || [];
|
// $FlowFixMe process.env not defined in electron API spec
|
||||||
|
disabledPlugins = JSON.parse(remote?.process.env.CONFIG || '{}').disabledPlugins || [];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load dynamic plugins
|
// Load dynamic plugins
|
||||||
try {
|
try {
|
||||||
JSON.parse(remoteEnv.PLUGINS || '[]').forEach(addIfNotAdded);
|
// $FlowFixMe process.env not defined in electron API spec
|
||||||
|
JSON.parse(remote?.process.env.PLUGINS || '[]').forEach(addIfNotAdded);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
maybeSnapTop,
|
maybeSnapTop,
|
||||||
SNAP_SIZE,
|
SNAP_SIZE,
|
||||||
} from '../../utils/snap.js';
|
} from '../../utils/snap.js';
|
||||||
import {styled} from 'flipper';
|
import {styled} from '../../ui';
|
||||||
|
|
||||||
const invariant = require('invariant');
|
const invariant = require('invariant');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
export {default as styled} from 'react-emotion';
|
||||||
export {default as Button} from './components/Button.js';
|
export {default as Button} from './components/Button.js';
|
||||||
export {default as ToggleButton} from './components/ToggleSwitch.js';
|
export {default as ToggleButton} from './components/ToggleSwitch.js';
|
||||||
export {
|
export {
|
||||||
|
|||||||
Reference in New Issue
Block a user