Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function findTransitiveDeps(
sortedChunkIds: readonly string[],
dependencies: readonly depGraph.Dependency[],
modules: { [id: string]: { inputs: readonly string[]; deps: readonly string[] } }
): Map> {
const pathToDep = new Map(
dependencies.map(dep => [dep.path, dep] as [string, depGraph.Dependency])
);
const graph = new depGraph.Graph(dependencies);
const chunkToTransitiveDepPathSet: Map> = new Map();
sortedChunkIds.forEach(chunkId => {
const chunkConfig = modules[chunkId];
const entryPoints = chunkConfig.inputs.map(input =>
assertNonNullable(
pathToDep.get(input),
`entryConfig.paths does not include the inputs: ${input}`
)
);
const depPaths = graph.order(...entryPoints).map(dep => dep.path);
chunkToTransitiveDepPathSet.set(chunkId, new Set(depPaths));
});
return chunkToTransitiveDepPathSet;
}