Add hook for accessing aggregated resolution cache

Reviewed By: mjesun

Differential Revision: D5775425

fbshipit-source-id: 9e1855d9a161f60d7163a208c5539264ba67d3fd
This commit is contained in:
Alexander Gugel 2017-09-14 18:40:21 -07:00 committed by Facebook Github Bot
parent 300cd924e0
commit db7ea0b5f7
1 changed files with 6 additions and 2 deletions

View File

@ -80,7 +80,7 @@ class ResolutionRequest<TModule: Moduleish, TPackage: Packageish> {
}
resolveDependency(fromModule: TModule, toModuleName: string): TModule {
const resHash = resolutionHash(fromModule.path, toModuleName);
const resHash = getResolutionCacheKey(fromModule.path, toModuleName);
const immediateResolution = this._immediateResolutionCache[resHash];
if (immediateResolution) {
@ -367,9 +367,13 @@ class ResolutionRequest<TModule: Moduleish, TPackage: Packageish> {
_resetResolutionCache() {
this._immediateResolutionCache = Object.create(null);
}
getResolutionCache(): {[key: string]: TModule} {
return this._immediateResolutionCache;
}
}
function resolutionHash(modulePath, depName) {
function getResolutionCacheKey(modulePath, depName) {
return `${path.resolve(modulePath)}:${depName}`;
}