mirror of https://github.com/status-im/metro.git
packager: getInverseDependencies: @flow
Reviewed By: davidaurelio Differential Revision: D5052190 fbshipit-source-id: ebfa2a698233e914b016fe50f790ee8aa758c4f2
This commit is contained in:
parent
02d57294fe
commit
2068e661a5
|
@ -5,17 +5,27 @@
|
|||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @flow
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
function resolveModuleRequires(resolutionResponse, module) {
|
||||
import type ResolutionResponse from '../DependencyGraph/ResolutionResponse';
|
||||
|
||||
function resolveModuleRequires<TModule: {hash(): string}, TOptions>(
|
||||
resolutionResponse: ResolutionResponse<TModule, TOptions>,
|
||||
module: TModule,
|
||||
) {
|
||||
const pairs = resolutionResponse.getResolvedDependencyPairs(module);
|
||||
return pairs
|
||||
? pairs.map(([, dependencyModule]) => dependencyModule)
|
||||
: [];
|
||||
return pairs ? pairs.map(([, dependencyModule]) => dependencyModule) : [];
|
||||
}
|
||||
|
||||
function getModuleDependents(cache, module) {
|
||||
function getModuleDependents<TModule>(
|
||||
cache: Map<TModule, Set<TModule>>,
|
||||
module: TModule,
|
||||
): Set<TModule> {
|
||||
let dependents = cache.get(module);
|
||||
if (!dependents) {
|
||||
dependents = new Set();
|
||||
|
@ -27,7 +37,9 @@ function getModuleDependents(cache, module) {
|
|||
/**
|
||||
* Returns an object that indicates in which module each module is required.
|
||||
*/
|
||||
function getInverseDependencies(resolutionResponse) {
|
||||
function getInverseDependencies<TModule: {hash(): string}, TOptions>(
|
||||
resolutionResponse: ResolutionResponse<TModule, TOptions>,
|
||||
): Map<TModule, Set<TModule>> {
|
||||
const cache = new Map();
|
||||
|
||||
resolutionResponse.dependencies.forEach(module => {
|
||||
|
|
Loading…
Reference in New Issue