refactor(ivy): ngcc - tidy up `DependencyResolver` helper method (#29643)

This method was poorly named for what it does, and did not have a
return type.

PR Close #29643
This commit is contained in:
Pete Bacon Darwin 2019-04-28 20:47:56 +01:00 committed by Andrew Kushnir
parent 78b5bd5174
commit 4c03208537
1 changed files with 14 additions and 8 deletions

View File

@ -6,8 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {resolve} from 'canonical-path';
import {DepGraph} from 'dependency-graph';
import {resolve} from 'path';
import {AbsoluteFsPath} from '../../../src/ngtsc/path';
import {Logger} from '../logging/logger';
@ -48,6 +48,11 @@ export interface IgnoredDependency {
dependencyPath: string;
}
export interface DependencyDiagnostics {
invalidEntryPoints: InvalidEntryPoint[];
ignoredDependencies: IgnoredDependency[];
}
/**
* A list of entry-points, sorted by their dependencies.
*
@ -57,11 +62,7 @@ export interface IgnoredDependency {
* Some entry points or their dependencies may be have been ignored. These are captured for
* diagnostic purposes in `invalidEntryPoints` and `ignoredDependencies` respectively.
*/
export interface SortedEntryPointsInfo {
entryPoints: EntryPoint[];
invalidEntryPoints: InvalidEntryPoint[];
ignoredDependencies: IgnoredDependency[];
}
export interface SortedEntryPointsInfo extends DependencyDiagnostics { entryPoints: EntryPoint[]; }
/**
* A class that resolves dependencies between entry-points.
@ -77,7 +78,8 @@ export class DependencyResolver {
*/
sortEntryPointsByDependency(entryPoints: EntryPoint[], target?: EntryPoint):
SortedEntryPointsInfo {
const {invalidEntryPoints, ignoredDependencies, graph} = this.createDependencyInfo(entryPoints);
const {invalidEntryPoints, ignoredDependencies, graph} =
this.computeDependencyGraph(entryPoints);
let sortedEntryPointNodes: string[];
if (target) {
@ -100,7 +102,7 @@ export class DependencyResolver {
* The graph only holds entry-points that ngcc cares about and whose dependencies
* (direct and transitive) all exist.
*/
private createDependencyInfo(entryPoints: EntryPoint[]) {
private computeDependencyGraph(entryPoints: EntryPoint[]): DependencyGraph {
const invalidEntryPoints: InvalidEntryPoint[] = [];
const ignoredDependencies: IgnoredDependency[] = [];
const graph = new DepGraph<EntryPoint>();
@ -167,3 +169,7 @@ function getEntryPointPath(entryPoint: EntryPoint): AbsoluteFsPath {
}
throw new Error(`There is no format with import statements in '${entryPoint.path}' entry-point.`);
}
interface DependencyGraph extends DependencyDiagnostics {
graph: DepGraph<EntryPoint>;
}