Fix plugin resolution on Linux
Summary: Linux appears to spawn a completely separate browser process whereas MacOS either forks or uses a thread. Either way, Linux no longer has access to the parent process's environment variables we use to look up plugins. Using the remote module fixes that. In the medium term, we should convert the `plugin` module to not rely on import effects and instead use the IPC mechanism, making the plugin resolution asynchronous: https://electronjs.org/docs/api/web-contents#contentssendchannel-arg1-arg2- That would also allow us to do the plugin resolution while starting up the browser window, lowering the startup time. Reviewed By: danielbuechele Differential Revision: D9423628 fbshipit-source-id: 76351f267864147c4494aadaf4e16ea636952118
This commit is contained in:
committed by
Facebook Github Bot
parent
7852a3886b
commit
33f34650df
@@ -10,8 +10,11 @@ import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import * as Sonar from 'sonar';
|
||||
import {SonarPlugin, SonarBasePlugin} from '../plugin.js';
|
||||
import {remote} from 'electron';
|
||||
|
||||
const plugins = new Map();
|
||||
// $FlowFixMe process.env not defined in electron API spec
|
||||
const remoteEnv = remote.process.env;
|
||||
|
||||
// expose Sonar and exact globally for dynamically loaded plugins
|
||||
window.React = React;
|
||||
@@ -26,15 +29,14 @@ const addIfNotAdded = plugin => {
|
||||
|
||||
let disabledPlugins = [];
|
||||
try {
|
||||
disabledPlugins =
|
||||
JSON.parse(window.process.env.CONFIG || '{}').disabledPlugins || [];
|
||||
disabledPlugins = JSON.parse(remoteEnv.CONFIG || '{}').disabledPlugins || [];
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
// Load dynamic plugins
|
||||
try {
|
||||
JSON.parse(window.process.env.PLUGINS || '[]').forEach(addIfNotAdded);
|
||||
JSON.parse(remoteEnv.PLUGINS || '[]').forEach(addIfNotAdded);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user