From db7ea0b5f778c22a8fc906b5fc18b74c0c4a3d75 Mon Sep 17 00:00:00 2001 From: Alexander Gugel Date: Thu, 14 Sep 2017 18:40:21 -0700 Subject: [PATCH] Add hook for accessing aggregated resolution cache Reviewed By: mjesun Differential Revision: D5775425 fbshipit-source-id: 9e1855d9a161f60d7163a208c5539264ba67d3fd --- .../src/node-haste/DependencyGraph/ResolutionRequest.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js b/packages/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js index 8dd48b4e..a303c6ea 100644 --- a/packages/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js +++ b/packages/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js @@ -80,7 +80,7 @@ class ResolutionRequest { } 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 { _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}`; }