Summary: "flipper-pkg" added ~2MB to Flipper disttributive size, because of heavy dependencies which are only required for CLI functionality. See size warning in diff D21068373 in this stack where I added pkg as dependency to flipper. Here I'm splitting it into library and CLI packages, so Flipper app will only reference the library. Reviewed By: passy Differential Revision: D21087336 fbshipit-source-id: d9d62f1e75a835d1c0fa78ff1addb0d9a761a9c7
37 lines
1.2 KiB
TypeScript
37 lines
1.2 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 fs from 'fs-extra';
|
|
import path from 'path';
|
|
import {getWatchFolders} from 'flipper-pkg-lib';
|
|
import {appDir, pluginsDir} from './paths';
|
|
|
|
/**
|
|
* Flipper references code from below plugins directly. Such directly referenced plugins
|
|
* and their dependencies should be added as watch folders so Metro bundled can resolve them.
|
|
*/
|
|
const pluginsReferencedDirectlyFromFlipper = [
|
|
path.join(pluginsDir, 'navigation'),
|
|
path.join(pluginsDir, 'fb', 'layout', 'sidebar_extensions'),
|
|
path.join(pluginsDir, 'fb', 'mobileconfig'),
|
|
path.join(pluginsDir, 'fb', 'watch'),
|
|
];
|
|
|
|
export default async function getAppWatchFolders() {
|
|
const getWatchFoldersResults = await Promise.all(
|
|
[appDir, ...pluginsReferencedDirectlyFromFlipper].map((dir) =>
|
|
getWatchFolders(dir),
|
|
),
|
|
);
|
|
const watchFolders = ([] as string[]).concat(...getWatchFoldersResults);
|
|
return watchFolders
|
|
.filter((value, index, self) => self.indexOf(value) === index)
|
|
.filter(fs.pathExistsSync);
|
|
}
|