Fallback to Haste name if file path cannot be found when bundling

Reviewed By: rafeca

Differential Revision: D6567420

fbshipit-source-id: 84821b31b45bc7eeb302eef83531cc9a4e666406
This commit is contained in:
Burak Yigit Kaya 2017-12-14 11:43:21 -08:00 committed by Facebook Github Bot
parent 86914666e5
commit 82b508296d
1 changed files with 13 additions and 0 deletions

View File

@ -284,6 +284,19 @@ class DependencyGraph extends EventEmitter {
}
}
// If we failed to find a file, maybe this is just a Haste name so try that
// TODO: We should prefer Haste name resolution first ideally since it is faster
// TODO: Ideally, we should not do any `path.parse().name` here and just use the
// name, but in `metro/src/Server/index.js` we append `'.js'` to all names
// so until that changes, we have to do this.
const potentialPath = this._moduleMap.getModule(
path.parse(filePath).name,
null,
);
if (potentialPath) {
return potentialPath;
}
throw new NotFoundError(
'Cannot find entry file %s in any of the roots: %j',
filePath,