1 | /// <amd-module name="@angular/compiler-cli/ngcc/src/dependencies/dependency_host" />
|
---|
2 | /**
|
---|
3 | * @license
|
---|
4 | * Copyright Google LLC All Rights Reserved.
|
---|
5 | *
|
---|
6 | * Use of this source code is governed by an MIT-style license that can be
|
---|
7 | * found in the LICENSE file at https://angular.io/license
|
---|
8 | */
|
---|
9 | import { AbsoluteFsPath, PathSegment, ReadonlyFileSystem } from '../../../src/ngtsc/file_system';
|
---|
10 | import { EntryPoint } from '../packages/entry_point';
|
---|
11 | import { ModuleResolver } from './module_resolver';
|
---|
12 | export interface DependencyHost {
|
---|
13 | collectDependencies(entryPointPath: AbsoluteFsPath, { dependencies, missing, deepImports }: DependencyInfo): void;
|
---|
14 | }
|
---|
15 | export interface DependencyInfo {
|
---|
16 | dependencies: Set<AbsoluteFsPath>;
|
---|
17 | missing: Set<AbsoluteFsPath | PathSegment>;
|
---|
18 | deepImports: Set<AbsoluteFsPath>;
|
---|
19 | }
|
---|
20 | export interface EntryPointWithDependencies {
|
---|
21 | entryPoint: EntryPoint;
|
---|
22 | depInfo: DependencyInfo;
|
---|
23 | }
|
---|
24 | export declare function createDependencyInfo(): DependencyInfo;
|
---|
25 | export declare abstract class DependencyHostBase implements DependencyHost {
|
---|
26 | protected fs: ReadonlyFileSystem;
|
---|
27 | protected moduleResolver: ModuleResolver;
|
---|
28 | constructor(fs: ReadonlyFileSystem, moduleResolver: ModuleResolver);
|
---|
29 | /**
|
---|
30 | * Find all the dependencies for the entry-point at the given path.
|
---|
31 | *
|
---|
32 | * @param entryPointPath The absolute path to the JavaScript file that represents an entry-point.
|
---|
33 | * @param dependencyInfo An object containing information about the dependencies of the
|
---|
34 | * entry-point, including those that were missing or deep imports into other entry-points. The
|
---|
35 | * sets in this object will be updated with new information about the entry-point's dependencies.
|
---|
36 | */
|
---|
37 | collectDependencies(entryPointPath: AbsoluteFsPath, { dependencies, missing, deepImports }: DependencyInfo): void;
|
---|
38 | /**
|
---|
39 | * Find all the dependencies for the provided paths.
|
---|
40 | *
|
---|
41 | * @param files The list of absolute paths of JavaScript files to scan for dependencies.
|
---|
42 | * @param dependencyInfo An object containing information about the dependencies of the
|
---|
43 | * entry-point, including those that were missing or deep imports into other entry-points. The
|
---|
44 | * sets in this object will be updated with new information about the entry-point's dependencies.
|
---|
45 | */
|
---|
46 | collectDependenciesInFiles(files: AbsoluteFsPath[], { dependencies, missing, deepImports }: DependencyInfo): void;
|
---|
47 | /**
|
---|
48 | * Compute the dependencies of the given file.
|
---|
49 | *
|
---|
50 | * @param file An absolute path to the file whose dependencies we want to get.
|
---|
51 | * @param dependencies A set that will have the absolute paths of resolved entry points added to
|
---|
52 | * it.
|
---|
53 | * @param missing A set that will have the dependencies that could not be found added to it.
|
---|
54 | * @param deepImports A set that will have the import paths that exist but cannot be mapped to
|
---|
55 | * entry-points, i.e. deep-imports.
|
---|
56 | * @param alreadySeen A set that is used to track internal dependencies to prevent getting stuck
|
---|
57 | * in a circular dependency loop.
|
---|
58 | */
|
---|
59 | protected recursivelyCollectDependencies(file: AbsoluteFsPath, dependencies: Set<AbsoluteFsPath>, missing: Set<string>, deepImports: Set<string>, alreadySeen: Set<AbsoluteFsPath>): void;
|
---|
60 | protected abstract canSkipFile(fileContents: string): boolean;
|
---|
61 | protected abstract extractImports(file: AbsoluteFsPath, fileContents: string): Set<string>;
|
---|
62 | /**
|
---|
63 | * Resolve the given `importPath` from `file` and add it to the appropriate set.
|
---|
64 | *
|
---|
65 | * If the import is local to this package then follow it by calling
|
---|
66 | * `recursivelyCollectDependencies()`.
|
---|
67 | *
|
---|
68 | * @returns `true` if the import was resolved (to an entry-point, a local import, or a
|
---|
69 | * deep-import), `false` otherwise.
|
---|
70 | */
|
---|
71 | protected processImport(importPath: string, file: AbsoluteFsPath, dependencies: Set<AbsoluteFsPath>, missing: Set<string>, deepImports: Set<string>, alreadySeen: Set<AbsoluteFsPath>): boolean;
|
---|
72 | /**
|
---|
73 | * Processes the file if it has not already been seen. This will also recursively process
|
---|
74 | * all files that are imported from the file, while taking the set of already seen files
|
---|
75 | * into account.
|
---|
76 | */
|
---|
77 | protected processFile(file: AbsoluteFsPath, dependencies: Set<AbsoluteFsPath>, missing: Set<string>, deepImports: Set<string>, alreadySeen: Set<AbsoluteFsPath>): void;
|
---|
78 | }
|
---|