1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | /// <amd-module name="@angular/compiler-cli/ngcc/src/dependencies/dependency_resolver" />
|
---|
9 | import { DepGraph } from 'dependency-graph';
|
---|
10 | import { ReadonlyFileSystem } from '../../../src/ngtsc/file_system';
|
---|
11 | import { Logger } from '../../../src/ngtsc/logging';
|
---|
12 | import { NgccConfiguration } from '../packages/configuration';
|
---|
13 | import { EntryPoint, EntryPointFormat } from '../packages/entry_point';
|
---|
14 | import { PartiallyOrderedList } from '../utils';
|
---|
15 | import { DependencyHost, EntryPointWithDependencies } from './dependency_host';
|
---|
16 | /**
|
---|
17 | * Holds information about entry points that are removed because
|
---|
18 | * they have dependencies that are missing (directly or transitively).
|
---|
19 | *
|
---|
20 | * This might not be an error, because such an entry point might not actually be used
|
---|
21 | * in the application. If it is used then the `ngc` application compilation would
|
---|
22 | * fail also, so we don't need ngcc to catch this.
|
---|
23 | *
|
---|
24 | * For example, consider an application that uses the `@angular/router` package.
|
---|
25 | * This package includes an entry-point called `@angular/router/upgrade`, which has a dependency
|
---|
26 | * on the `@angular/upgrade` package.
|
---|
27 | * If the application never uses code from `@angular/router/upgrade` then there is no need for
|
---|
28 | * `@angular/upgrade` to be installed.
|
---|
29 | * In this case the ngcc tool should just ignore the `@angular/router/upgrade` end-point.
|
---|
30 | */
|
---|
31 | export interface InvalidEntryPoint {
|
---|
32 | entryPoint: EntryPoint;
|
---|
33 | missingDependencies: string[];
|
---|
34 | }
|
---|
35 | /**
|
---|
36 | * Holds information about dependencies of an entry-point that do not need to be processed
|
---|
37 | * by the ngcc tool.
|
---|
38 | *
|
---|
39 | * For example, the `rxjs` package does not contain any Angular decorators that need to be
|
---|
40 | * compiled and so this can be safely ignored by ngcc.
|
---|
41 | */
|
---|
42 | export interface IgnoredDependency {
|
---|
43 | entryPoint: EntryPoint;
|
---|
44 | dependencyPath: string;
|
---|
45 | }
|
---|
46 | export interface DependencyDiagnostics {
|
---|
47 | invalidEntryPoints: InvalidEntryPoint[];
|
---|
48 | ignoredDependencies: IgnoredDependency[];
|
---|
49 | }
|
---|
50 | /**
|
---|
51 | * Represents a partially ordered list of entry-points.
|
---|
52 | *
|
---|
53 | * The entry-points' order/precedence is such that dependent entry-points always come later than
|
---|
54 | * their dependencies in the list.
|
---|
55 | *
|
---|
56 | * See `DependencyResolver#sortEntryPointsByDependency()`.
|
---|
57 | */
|
---|
58 | export declare type PartiallyOrderedEntryPoints = PartiallyOrderedList<EntryPoint>;
|
---|
59 | /**
|
---|
60 | * A list of entry-points, sorted by their dependencies, and the dependency graph.
|
---|
61 | *
|
---|
62 | * The `entryPoints` array will be ordered so that no entry point depends upon an entry point that
|
---|
63 | * appears later in the array.
|
---|
64 | *
|
---|
65 | * Some entry points or their dependencies may have been ignored. These are captured for
|
---|
66 | * diagnostic purposes in `invalidEntryPoints` and `ignoredDependencies` respectively.
|
---|
67 | */
|
---|
68 | export interface SortedEntryPointsInfo extends DependencyDiagnostics {
|
---|
69 | entryPoints: PartiallyOrderedEntryPoints;
|
---|
70 | graph: DepGraph<EntryPoint>;
|
---|
71 | }
|
---|
72 | /**
|
---|
73 | * A class that resolves dependencies between entry-points.
|
---|
74 | */
|
---|
75 | export declare class DependencyResolver {
|
---|
76 | private fs;
|
---|
77 | private logger;
|
---|
78 | private config;
|
---|
79 | private hosts;
|
---|
80 | private typingsHost;
|
---|
81 | constructor(fs: ReadonlyFileSystem, logger: Logger, config: NgccConfiguration, hosts: Partial<Record<EntryPointFormat, DependencyHost>>, typingsHost: DependencyHost);
|
---|
82 | /**
|
---|
83 | * Sort the array of entry points so that the dependant entry points always come later than
|
---|
84 | * their dependencies in the array.
|
---|
85 | * @param entryPoints An array entry points to sort.
|
---|
86 | * @param target If provided, only return entry-points depended on by this entry-point.
|
---|
87 | * @returns the result of sorting the entry points by dependency.
|
---|
88 | */
|
---|
89 | sortEntryPointsByDependency(entryPoints: EntryPointWithDependencies[], target?: EntryPoint): SortedEntryPointsInfo;
|
---|
90 | getEntryPointWithDependencies(entryPoint: EntryPoint): EntryPointWithDependencies;
|
---|
91 | /**
|
---|
92 | * Computes a dependency graph of the given entry-points.
|
---|
93 | *
|
---|
94 | * The graph only holds entry-points that ngcc cares about and whose dependencies
|
---|
95 | * (direct and transitive) all exist.
|
---|
96 | */
|
---|
97 | private computeDependencyGraph;
|
---|
98 | private getEntryPointFormatInfo;
|
---|
99 | /**
|
---|
100 | * Filter out the deepImports that can be ignored, according to this entryPoint's config.
|
---|
101 | */
|
---|
102 | private filterIgnorableDeepImports;
|
---|
103 | }
|
---|