Fixed error with 3rd plugin compilation in dev mode
Summary: Fixed error "SHA-1 for file is not computed" on 3rd party plugin compilation in dev mode. The error started to appear after moving to yarn workspaces. Changelog: Fixed error "SHA-1 for file is not computed" on 3rd party plugin compilation in dev mode (yarn start). Reviewed By: mweststrate Differential Revision: D20789712 fbshipit-source-id: bbc2fcca197955da50ebf2b51a1fd9cb62f79727
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5dc3ab4ea2
commit
0711617c63
@@ -21,6 +21,9 @@ import getWatchFolders from './get-watch-folders';
|
|||||||
|
|
||||||
const HOME_DIR = homedir();
|
const HOME_DIR = homedir();
|
||||||
|
|
||||||
|
let metroDir: string | undefined;
|
||||||
|
const metroDirPromise = getMetroDir().then((dir) => (metroDir = dir));
|
||||||
|
|
||||||
const DEFAULT_COMPILE_OPTIONS: CompileOptions = {
|
const DEFAULT_COMPILE_OPTIONS: CompileOptions = {
|
||||||
force: false,
|
force: false,
|
||||||
failSilently: true,
|
failSilently: true,
|
||||||
@@ -236,6 +239,19 @@ async function mostRecentlyChanged(dir: string) {
|
|||||||
.map((f) => fs.lstatSync(f).ctime)
|
.map((f) => fs.lstatSync(f).ctime)
|
||||||
.reduce((a, b) => (a > b ? a : b), new Date(0));
|
.reduce((a, b) => (a > b ? a : b), new Date(0));
|
||||||
}
|
}
|
||||||
|
async function getMetroDir() {
|
||||||
|
let dir = __dirname;
|
||||||
|
while (true) {
|
||||||
|
const dirToCheck = path.join(dir, 'node_modules', 'metro');
|
||||||
|
if (await fs.pathExists(dirToCheck)) return dirToCheck;
|
||||||
|
const nextDir = path.dirname(dir);
|
||||||
|
if (!nextDir || nextDir === '' || nextDir === dir) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dir = nextDir;
|
||||||
|
}
|
||||||
|
return __dirname;
|
||||||
|
}
|
||||||
async function compilePlugin(
|
async function compilePlugin(
|
||||||
pluginInfo: PluginInfo,
|
pluginInfo: PluginInfo,
|
||||||
pluginCache: string,
|
pluginCache: string,
|
||||||
@@ -273,7 +289,9 @@ async function compilePlugin(
|
|||||||
{
|
{
|
||||||
reporter: {update: () => {}},
|
reporter: {update: () => {}},
|
||||||
projectRoot: rootDir,
|
projectRoot: rootDir,
|
||||||
watchFolders: [__dirname].concat(await getWatchFolders(rootDir)),
|
watchFolders: [metroDir || (await metroDirPromise)].concat(
|
||||||
|
await getWatchFolders(rootDir),
|
||||||
|
),
|
||||||
serializer: {
|
serializer: {
|
||||||
getRunModuleStatement: (moduleID: string) =>
|
getRunModuleStatement: (moduleID: string) =>
|
||||||
`module.exports = global.__r(${moduleID}).default;`,
|
`module.exports = global.__r(${moduleID}).default;`,
|
||||||
|
|||||||
Reference in New Issue
Block a user