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:

committed by
atscott

parent
5c0bdae809
commit
f3ccd29e7b
@ -11,6 +11,7 @@
|
||||
import * as os from 'os';
|
||||
|
||||
import {AbsoluteFsPath, FileSystem, resolve} from '../../src/ngtsc/file_system';
|
||||
import {ParsedConfiguration} from '../../src/perform_compile';
|
||||
|
||||
import {CommonJsDependencyHost} from './dependencies/commonjs_dependency_host';
|
||||
import {DependencyResolver} from './dependencies/dependency_resolver';
|
||||
@ -20,6 +21,7 @@ import {ModuleResolver} from './dependencies/module_resolver';
|
||||
import {UmdDependencyHost} from './dependencies/umd_dependency_host';
|
||||
import {DirectoryWalkerEntryPointFinder} from './entry_point_finder/directory_walker_entry_point_finder';
|
||||
import {EntryPointFinder} from './entry_point_finder/interface';
|
||||
import {ProgramBasedEntryPointFinder} from './entry_point_finder/program_based_entry_point_finder';
|
||||
import {TargetedEntryPointFinder} from './entry_point_finder/targeted_entry_point_finder';
|
||||
import {getAnalyzeEntryPointsFn} from './execution/analyze_entry_points';
|
||||
import {Executor} from './execution/api';
|
||||
@ -81,7 +83,8 @@ export function mainNgcc(options: AsyncNgccOptions|SyncNgccOptions): void|Promis
|
||||
targetEntryPointPath !== undefined ? resolve(basePath, targetEntryPointPath) : null;
|
||||
const finder = getEntryPointFinder(
|
||||
fileSystem, logger, dependencyResolver, config, entryPointManifest, absBasePath,
|
||||
absoluteTargetEntryPointPath, pathMappings);
|
||||
absoluteTargetEntryPointPath, pathMappings,
|
||||
options.findEntryPointsFromTsConfigProgram ? tsConfig : null, projectPath);
|
||||
if (finder instanceof TargetedEntryPointFinder &&
|
||||
!finder.targetNeedsProcessingOrCleaning(supportedPropertiesToConsider, compileAllFormats)) {
|
||||
logger.debug('The target entry-point has already been processed');
|
||||
@ -195,13 +198,15 @@ function getDependencyResolver(
|
||||
function getEntryPointFinder(
|
||||
fs: FileSystem, logger: Logger, resolver: DependencyResolver, config: NgccConfiguration,
|
||||
entryPointManifest: EntryPointManifest, basePath: AbsoluteFsPath,
|
||||
absoluteTargetEntryPointPath: AbsoluteFsPath|null,
|
||||
pathMappings: PathMappings|undefined): EntryPointFinder {
|
||||
absoluteTargetEntryPointPath: AbsoluteFsPath|null, pathMappings: PathMappings|undefined,
|
||||
tsConfig: ParsedConfiguration|null, projectPath: AbsoluteFsPath): EntryPointFinder {
|
||||
if (absoluteTargetEntryPointPath !== null) {
|
||||
return new TargetedEntryPointFinder(
|
||||
fs, config, logger, resolver, basePath, absoluteTargetEntryPointPath, pathMappings);
|
||||
} else {
|
||||
return new DirectoryWalkerEntryPointFinder(
|
||||
fs, config, logger, resolver, entryPointManifest, basePath, pathMappings);
|
||||
fs, config, logger, resolver, basePath, pathMappings, absoluteTargetEntryPointPath);
|
||||
} else if (tsConfig !== null) {
|
||||
return new ProgramBasedEntryPointFinder(
|
||||
fs, config, logger, resolver, basePath, tsConfig, projectPath);
|
||||
}
|
||||
return new DirectoryWalkerEntryPointFinder(
|
||||
fs, config, logger, resolver, entryPointManifest, basePath, pathMappings);
|
||||
}
|
||||
|
Reference in New Issue
Block a user