diff --git a/packager/react-packager/src/DependencyResolver/DependencyGraph/ResolutionRequest.js b/packager/react-packager/src/DependencyResolver/DependencyGraph/ResolutionRequest.js index e95237e64..879c53efa 100644 --- a/packager/react-packager/src/DependencyResolver/DependencyGraph/ResolutionRequest.js +++ b/packager/react-packager/src/DependencyResolver/DependencyGraph/ResolutionRequest.js @@ -118,14 +118,21 @@ class ResolutionRequest { ).then((dependencies) => [depNames, dependencies]) ).then(([depNames, dependencies]) => { if (allMocks) { - return mod.getName().then(name => { - if (allMocks[name]) { - const mockModule = - this._moduleCache.getModule(allMocks[name]); - depNames.push(name); - dependencies.push(mockModule); - mocks[name] = allMocks[name]; - } + const list = [mod.getName()]; + const pkg = mod.getPackage(); + if (pkg) { + list.push(pkg.getName()); + } + return Promise.all(list).then(names => { + names.forEach(name => { + if (allMocks[name] && !mocks[name]) { + const mockModule = + this._moduleCache.getModule(allMocks[name]); + depNames.push(name); + dependencies.push(mockModule); + mocks[name] = allMocks[name]; + } + }); return [depNames, dependencies]; }); } @@ -141,7 +148,7 @@ class ResolutionRequest { // module backing them. If a dependency cannot be found but there // exists a mock with the desired ID, resolve it and add it as // a dependency. - if (allMocks && allMocks[name]) { + if (allMocks && allMocks[name] && !mocks[name]) { const mockModule = this._moduleCache.getModule(allMocks[name]); mocks[name] = allMocks[name]; return filteredPairs.push([name, mockModule]);