refactor(compiler-cli): ngcc - track non-Angular entry-points (#29643)

Previously we completely ignored entry-points that had not been
compiled with Angular, since we do not need to compile them
with ngcc. But this makes it difficult to reason about dependencies
between entry-points that were compiled with Angular and those that
were not.

Now we do track these non-Angular compiled entry-points but they
are marked as `compiledByAngular: false`.

PR Close #29643
This commit is contained in:
Pete Bacon Darwin
2019-04-28 20:47:56 +01:00
committed by Andrew Kushnir
parent c2cf500da9
commit 321da5cc83
4 changed files with 69 additions and 38 deletions

View File

@ -83,8 +83,12 @@ export class DependencyResolver {
let sortedEntryPointNodes: string[];
if (target) {
sortedEntryPointNodes = graph.dependenciesOf(target.path);
sortedEntryPointNodes.push(target.path);
if (target.compiledByAngular) {
sortedEntryPointNodes = graph.dependenciesOf(target.path);
sortedEntryPointNodes.push(target.path);
} else {
sortedEntryPointNodes = [];
}
} else {
sortedEntryPointNodes = graph.overallOrder();
}
@ -107,11 +111,13 @@ export class DependencyResolver {
const ignoredDependencies: IgnoredDependency[] = [];
const graph = new DepGraph<EntryPoint>();
// Add the entry points to the graph as nodes
entryPoints.forEach(entryPoint => graph.addNode(entryPoint.path, entryPoint));
const angularEntryPoints = entryPoints.filter(entryPoint => entryPoint.compiledByAngular);
// Add the Angular compiled entry points to the graph as nodes
angularEntryPoints.forEach(entryPoint => graph.addNode(entryPoint.path, entryPoint));
// Now add the dependencies between them
entryPoints.forEach(entryPoint => {
angularEntryPoints.forEach(entryPoint => {
const entryPointPath = getEntryPointPath(entryPoint);
const {dependencies, missing, deepImports} = this.host.computeDependencies(entryPointPath);

View File

@ -33,6 +33,8 @@ export interface EntryPoint {
path: AbsoluteFsPath;
/** The path to a typings (.d.ts) file for this entry-point. */
typings: AbsoluteFsPath;
/** Is this EntryPoint compiled with the Angular View Engine compiler? */
compiledByAngular: boolean;
}
interface PackageJsonFormatProperties {
@ -89,9 +91,6 @@ export function getEntryPointInfo(
// Also there must exist a `metadata.json` file next to the typings entry-point.
const metadataPath =
path.resolve(entryPointPath, typings.replace(/\.d\.ts$/, '') + '.metadata.json');
if (!fs.existsSync(metadataPath)) {
return null;
}
const entryPointInfo: EntryPoint = {
name: entryPointPackageJson.name,
@ -99,6 +98,7 @@ export function getEntryPointInfo(
package: packagePath,
path: entryPointPath,
typings: AbsoluteFsPath.from(path.resolve(entryPointPath, typings)),
compiledByAngular: fs.existsSync(metadataPath),
};
return entryPointInfo;