source: trip-planner-front/node_modules/@angular/compiler-cli/ngcc/src/dependencies/module_resolver.d.ts@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 5.4 KB
Line 
1/// <amd-module name="@angular/compiler-cli/ngcc/src/dependencies/module_resolver" />
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 */
9import { AbsoluteFsPath, ReadonlyFileSystem } from '../../../src/ngtsc/file_system';
10import { PathMappings } from '../path_mappings';
11/**
12 * This is a very cut-down implementation of the TypeScript module resolution strategy.
13 *
14 * It is specific to the needs of ngcc and is not intended to be a drop-in replacement
15 * for the TS module resolver. It is used to compute the dependencies between entry-points
16 * that may be compiled by ngcc.
17 *
18 * The algorithm only finds `.js` files for internal/relative imports and paths to
19 * the folder containing the `package.json` of the entry-point for external imports.
20 *
21 * It can cope with nested `node_modules` folders and also supports `paths`/`baseUrl`
22 * configuration properties, as provided in a `ts.CompilerOptions` object.
23 */
24export declare class ModuleResolver {
25 private fs;
26 readonly relativeExtensions: string[];
27 private pathMappings;
28 constructor(fs: ReadonlyFileSystem, pathMappings?: PathMappings, relativeExtensions?: string[]);
29 /**
30 * Resolve an absolute path for the `moduleName` imported into a file at `fromPath`.
31 * @param moduleName The name of the import to resolve.
32 * @param fromPath The path to the file containing the import.
33 * @returns A path to the resolved module or null if missing.
34 * Specifically:
35 * * the absolute path to the package.json of an external module
36 * * a JavaScript file of an internal module
37 * * null if none exists.
38 */
39 resolveModuleImport(moduleName: string, fromPath: AbsoluteFsPath): ResolvedModule | null;
40 /**
41 * Convert the `pathMappings` into a collection of `PathMapper` functions.
42 */
43 private processPathMappings;
44 /**
45 * Try to resolve a module name, as a relative path, from the `fromPath`.
46 *
47 * As it is relative, it only looks for files that end in one of the `relativeExtensions`.
48 * For example: `${moduleName}.js` or `${moduleName}/index.js`.
49 * If neither of these files exist then the method returns `null`.
50 */
51 private resolveAsRelativePath;
52 /**
53 * Try to resolve the `moduleName`, by applying the computed `pathMappings` and
54 * then trying to resolve the mapped path as a relative or external import.
55 *
56 * Whether the mapped path is relative is defined as it being "below the `fromPath`" and not
57 * containing `node_modules`.
58 *
59 * If the mapped path is not relative but does not resolve to an external entry-point, then we
60 * check whether it would have resolved to a relative path, in which case it is marked as a
61 * "deep-import".
62 */
63 private resolveByPathMappings;
64 /**
65 * Try to resolve the `moduleName` as an external entry-point by searching the `node_modules`
66 * folders up the tree for a matching `.../node_modules/${moduleName}`.
67 *
68 * If a folder is found but the path does not contain a `package.json` then it is marked as a
69 * "deep-import".
70 */
71 private resolveAsEntryPoint;
72 /**
73 * Can we consider the given path as an entry-point to a package?
74 *
75 * This is achieved by checking for the existence of `${modulePath}/package.json`.
76 */
77 private isEntryPoint;
78 /**
79 * Apply the `pathMappers` to the `moduleName` and return all the possible
80 * paths that match.
81 *
82 * The mapped path is computed for each template in `mapping.templates` by
83 * replacing the `matcher.prefix` and `matcher.postfix` strings in `path with the
84 * `template.prefix` and `template.postfix` strings.
85 */
86 private findMappedPaths;
87 /**
88 * Attempt to find a mapped path for the given `path` and a `mapping`.
89 *
90 * The `path` matches the `mapping` if if it starts with `matcher.prefix` and ends with
91 * `matcher.postfix`.
92 *
93 * @returns the wildcard segment of a matched `path`, or `null` if no match.
94 */
95 private matchMapping;
96 /**
97 * Compute the candidate paths from the given mapping's templates using the matched
98 * string.
99 */
100 private computeMappedTemplates;
101 /**
102 * Search up the folder tree for the first folder that contains `package.json`
103 * or `null` if none is found.
104 */
105 private findPackagePath;
106}
107/** The result of resolving an import to a module. */
108export declare type ResolvedModule = ResolvedExternalModule | ResolvedRelativeModule | ResolvedDeepImport;
109/**
110 * A module that is external to the package doing the importing.
111 * In this case we capture the folder containing the entry-point.
112 */
113export declare class ResolvedExternalModule {
114 entryPointPath: AbsoluteFsPath;
115 constructor(entryPointPath: AbsoluteFsPath);
116}
117/**
118 * A module that is relative to the module doing the importing, and so internal to the
119 * source module's package.
120 */
121export declare class ResolvedRelativeModule {
122 modulePath: AbsoluteFsPath;
123 constructor(modulePath: AbsoluteFsPath);
124}
125/**
126 * A module that is external to the package doing the importing but pointing to a
127 * module that is deep inside a package, rather than to an entry-point of the package.
128 */
129export declare class ResolvedDeepImport {
130 importPath: AbsoluteFsPath;
131 constructor(importPath: AbsoluteFsPath);
132}
Note: See TracBrowser for help on using the repository browser.