Cleanup plugin watch folders
Summary: Watch folders weren't updated for cross plugin/flipper boundaries that have recently been removed Fix changes in several source folders not being picked up when fast refresh wasn't enabled Reviewed By: passy, aigoncharov Differential Revision: D32626139 fbshipit-source-id: 2c830ec8154ff859ce1e3ee101e5963162d2e0a2
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e742322eb1
commit
2b81be6c29
@@ -9,25 +9,12 @@
|
|||||||
|
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import pFilter from 'p-filter';
|
import pFilter from 'p-filter';
|
||||||
import path from 'path';
|
|
||||||
import {getWatchFolders} from 'flipper-pkg-lib';
|
import {getWatchFolders} from 'flipper-pkg-lib';
|
||||||
import {appDir, publicPluginsDir, fbPluginsDir} from './paths';
|
import {appDir} 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(publicPluginsDir, 'navigation'),
|
|
||||||
path.join(fbPluginsDir, 'mobileconfig'),
|
|
||||||
path.join(fbPluginsDir, 'watch'),
|
|
||||||
];
|
|
||||||
|
|
||||||
export default async function getAppWatchFolders() {
|
export default async function getAppWatchFolders() {
|
||||||
const getWatchFoldersResults = await Promise.all(
|
const getWatchFoldersResults = await Promise.all(
|
||||||
[appDir, ...pluginsReferencedDirectlyFromFlipper].map((dir) =>
|
[appDir].map((dir) => getWatchFolders(dir)),
|
||||||
getWatchFolders(dir),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
const watchFolders = ([] as string[]).concat(...getWatchFoldersResults);
|
const watchFolders = ([] as string[]).concat(...getWatchFoldersResults);
|
||||||
return pFilter(
|
return pFilter(
|
||||||
|
|||||||
@@ -244,6 +244,8 @@ async function startMetroServer(app: Express, server: http.Server) {
|
|||||||
const watchFolders = (await getAppWatchFolders()).concat(
|
const watchFolders = (await getAppWatchFolders()).concat(
|
||||||
await getPluginSourceFolders(),
|
await getPluginSourceFolders(),
|
||||||
);
|
);
|
||||||
|
console.log('Source dirs\n\t' + watchFolders.join('\n\t'));
|
||||||
|
|
||||||
const baseConfig = await Metro.loadConfig();
|
const baseConfig = await Metro.loadConfig();
|
||||||
const config = Object.assign({}, baseConfig, {
|
const config = Object.assign({}, baseConfig, {
|
||||||
projectRoot: rootDir,
|
projectRoot: rootDir,
|
||||||
@@ -339,7 +341,15 @@ async function startWatchChanges(io: socketIo.Server) {
|
|||||||
const watchman = new Watchman(path.resolve(__dirname, '..'));
|
const watchman = new Watchman(path.resolve(__dirname, '..'));
|
||||||
await watchman.initialize();
|
await watchman.initialize();
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
['app', 'pkg', 'doctor', 'plugin-lib', 'flipper-plugin'].map((dir) =>
|
[
|
||||||
|
'app',
|
||||||
|
'pkg',
|
||||||
|
'doctor',
|
||||||
|
'plugin-lib',
|
||||||
|
'flipper-plugin',
|
||||||
|
'flipper-common',
|
||||||
|
'flipper-ui-core',
|
||||||
|
].map((dir) =>
|
||||||
watchman.startWatchFiles(
|
watchman.startWatchFiles(
|
||||||
dir,
|
dir,
|
||||||
() => {
|
() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user