Summary:
- Removed compilation on startup which is not required anymore after switching to plugin spec v2.
- Removed from Node process ("static" package) all the dependencies which are not required anymore: e.g. metro, babel etc.
- Plugin loading code from node process moved to browser process and made asyncronous.
Some expected benefits after these changes:
1) Reduced size of Flipper bundle (~4.5MB reduction for lzma package in my tests) as well as startup time. It's hard to say the exact startup time difference as it is very machine-dependent, and on my machine it was already fast ~1500ms (vs 5500ms for p95) and decreased by just 100ms. But I think we should definitely see some improvements on "launch time" analytics graph for p95/p99.
2) Plugin loading is async now and happens when UI is already shown, so perceptive startup time should be also better now.
3) All plugin loading code is now consolidated in "app/dispatcher/plugins.tsx" instead of being splitted between Node and Browser processes as before. So it will be easier to debug plugin loading.
4) Now it is possible to apply updates of plugins by simple refresh of browser window instead of full Electron process restart as before.
5) 60% less code in Node process. This is good because it is harder to debug changes in Node process than in Browser process, especially taking in account differences between dev/release builds. Because of this Node process often ended up broken after changes. Hopefully now it will be more stable.
Changelog: changed the way of plugin loading, and removed obsolete dependencies, which should reduce bundle size and startup time.
Reviewed By: passy
Differential Revision: D23682756
fbshipit-source-id: 8445c877234b41c73853cebe585e2fdb1638b2c9
64 lines
1.5 KiB
TypeScript
64 lines
1.5 KiB
TypeScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import path from 'path';
|
|
import os from 'os';
|
|
import fs from 'fs';
|
|
|
|
export type Config = {
|
|
pluginPaths?: string[];
|
|
disabledPlugins?: string[];
|
|
lastWindowPosition?: {
|
|
x: number;
|
|
y: number;
|
|
width: number;
|
|
height: number;
|
|
};
|
|
updater?: boolean | undefined;
|
|
launcherMsg?: string | undefined;
|
|
updaterEnabled?: boolean;
|
|
launcherEnabled?: boolean;
|
|
};
|
|
|
|
export default function setup(argv: any) {
|
|
// ensure .flipper folder and config exist
|
|
const flipperDir = path.join(os.homedir(), '.flipper');
|
|
if (!fs.existsSync(flipperDir)) {
|
|
fs.mkdirSync(flipperDir);
|
|
}
|
|
|
|
const configPath = path.join(flipperDir, 'config.json');
|
|
let config: Config = {
|
|
pluginPaths: [],
|
|
disabledPlugins: [],
|
|
};
|
|
|
|
try {
|
|
config = {
|
|
...config,
|
|
...JSON.parse(fs.readFileSync(configPath).toString()),
|
|
};
|
|
} catch (e) {
|
|
// file not readable or not parsable, overwrite it with the new config
|
|
console.warn(`Failed to read ${configPath}: ${e}`);
|
|
console.info('Writing new default config.');
|
|
fs.writeFileSync(configPath, JSON.stringify(config));
|
|
}
|
|
|
|
// Non-persistent CLI arguments.
|
|
config = {
|
|
...config,
|
|
updaterEnabled: argv.updater,
|
|
launcherEnabled: argv.launcher,
|
|
launcherMsg: argv.launcherMsg,
|
|
};
|
|
|
|
return {config, configPath};
|
|
}
|