mirror of https://github.com/status-im/metro.git
Add hook for accessing aggregated resolution cache
Reviewed By: mjesun Differential Revision: D5775425 fbshipit-source-id: 9e1855d9a161f60d7163a208c5539264ba67d3fd
This commit is contained in:
parent
300cd924e0
commit
db7ea0b5f7
|
@ -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}`;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue