From 4c032085373bd66916856f3e4ab74b8374a6e208 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Sun, 28 Apr 2019 20:47:56 +0100 Subject: [PATCH] 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 --- .../ngcc/src/packages/dependency_resolver.ts | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/compiler-cli/ngcc/src/packages/dependency_resolver.ts b/packages/compiler-cli/ngcc/src/packages/dependency_resolver.ts index 59737ed322..ef37a548a3 100644 --- a/packages/compiler-cli/ngcc/src/packages/dependency_resolver.ts +++ b/packages/compiler-cli/ngcc/src/packages/dependency_resolver.ts @@ -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(); @@ -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; +}