feat(ngcc): implement a program-based entry-point finder (#37075)

This finder is designed to only process entry-points that are reachable
by the program defined by a tsconfig.json file.

It is triggered by calling `mainNgcc()` with the `findEntryPointsFromTsConfigProgram`
option set to true. It is ignored if a `targetEntryPointPath` has been
provided as well.

It is triggered from the command line by adding the `--use-program-dependencies`
option, which is also ignored if the `--target` option has been provided.

Using this option can speed up processing in cases where there is a large
number of dependencies installed but only a small proportion of the
entry-points are actually imported into the application.

PR Close #37075
This commit is contained in:
Pete Bacon Darwin
2020-06-04 08:43:05 +01:00
committed by atscott
parent 07a8016118
commit 57411c85b9
11 changed files with 549 additions and 216 deletions

View File

@ -124,6 +124,14 @@ export interface SyncNgccOptions {
* If `null`, ngcc will not attempt to load any TS config file at all.
*/
tsConfigPath?: string|null;
/**
* Use the program defined in the loaded tsconfig.json (if available - see
* `tsConfigPath` option) to identify the entry-points that should be processed.
* If this is set to `true` then only the entry-points reachable from the given
* program (and their dependencies) will be processed.
*/
findEntryPointsFromTsConfigProgram?: boolean;
}
/**
@ -136,7 +144,8 @@ export type AsyncNgccOptions = Omit<SyncNgccOptions, 'async'>&{async: true};
*/
export type NgccOptions = AsyncNgccOptions|SyncNgccOptions;
export type OptionalNgccOptionKeys = 'targetEntryPointPath'|'tsConfigPath'|'pathMappings';
export type OptionalNgccOptionKeys =
'targetEntryPointPath'|'tsConfigPath'|'pathMappings'|'findEntryPointsFromTsConfigProgram';
export type RequiredNgccOptions = Required<Omit<NgccOptions, OptionalNgccOptionKeys>>;
export type OptionalNgccOptions = Pick<NgccOptions, OptionalNgccOptionKeys>;
export type SharedSetup = {