refactor(ngcc): remove unused EntryPointProcessingMetadata data and types (#32427)
				
					
				
			Previously, `ngcc` needed to store some metadata related to the processing of each entry-point. This metadata was stored in a `Map`, in the form of `EntryPointProcessingMetadata` and passed around as needed. After some recent refactorings, it turns out that this metadata (with its only remaining property, `hasProcessedTypings`) was no longer used, because the relevant information was extracted from other sources (such as the `processDts` property on `Task`s). This commit cleans up the code by removing the unused code and types. PR Close #32427
This commit is contained in:
		
							parent
							
								
									9270d3f279
								
							
						
					
					
						commit
						0cf94e3ed5
					
				| @ -8,11 +8,14 @@ | ||||
| 
 | ||||
| import {EntryPoint, EntryPointJsonProperty} from '../packages/entry_point'; | ||||
| 
 | ||||
| /** The type of the function that analyzes entry-points and creates the list of tasks. */ | ||||
| export type AnalyzeEntryPointsFn = () => { | ||||
|   processingMetadataPerEntryPoint: Map<string, EntryPointProcessingMetadata>; | ||||
|   tasks: Task[]; | ||||
| }; | ||||
| 
 | ||||
| /** | ||||
|  * The type of the function that analyzes entry-points and creates the list of tasks. | ||||
|  * | ||||
|  * @return A list of tasks that need to be executed in order to process the necessary format | ||||
|  *         properties for all entry-points. | ||||
|  */ | ||||
| export type AnalyzeEntryPointsFn = () => Task[]; | ||||
| 
 | ||||
| /** The type of the function that can process/compile a task. */ | ||||
| export type CompileFn = (task: Task) => void; | ||||
| @ -29,15 +32,6 @@ export interface Executor { | ||||
|       void|Promise<void>; | ||||
| } | ||||
| 
 | ||||
| /** Represents metadata related to the processing of an entry-point. */ | ||||
| export interface EntryPointProcessingMetadata { | ||||
|   /** | ||||
|    * Whether the typings for the entry-point have been successfully processed (or were already | ||||
|    * processed). | ||||
|    */ | ||||
|   hasProcessedTypings: boolean; | ||||
| } | ||||
| 
 | ||||
| /** Represents a unit of work: processing a specific format property of an entry-point. */ | ||||
| export interface Task { | ||||
|   /** The `EntryPoint` which needs to be processed as part of the task. */ | ||||
|  | ||||
| @ -22,10 +22,9 @@ export class SingleProcessExecutor implements Executor { | ||||
|   execute(analyzeEntryPoints: AnalyzeEntryPointsFn, createCompileFn: CreateCompileFn): void { | ||||
|     this.logger.debug(`Running ngcc on ${this.constructor.name}.`); | ||||
| 
 | ||||
|     const {processingMetadataPerEntryPoint, tasks} = analyzeEntryPoints(); | ||||
|     const compile = createCompileFn( | ||||
|         (task, outcome) => | ||||
|             onTaskCompleted(this.pkgJsonUpdater, processingMetadataPerEntryPoint, task, outcome)); | ||||
|     const tasks = analyzeEntryPoints(); | ||||
|     const compile = | ||||
|         createCompileFn((task, outcome) => onTaskCompleted(this.pkgJsonUpdater, task, outcome)); | ||||
| 
 | ||||
|     // Process all tasks.
 | ||||
|     for (const task of tasks) { | ||||
|  | ||||
| @ -11,14 +11,12 @@ import {markAsProcessed} from '../packages/build_marker'; | ||||
| import {PackageJsonFormatProperties} from '../packages/entry_point'; | ||||
| import {PackageJsonUpdater} from '../writing/package_json_updater'; | ||||
| 
 | ||||
| import {EntryPointProcessingMetadata, Task, TaskProcessingOutcome} from './api'; | ||||
| import {Task, TaskProcessingOutcome} from './api'; | ||||
| 
 | ||||
| 
 | ||||
| /** A helper function for handling a task's being completed. */ | ||||
| export const onTaskCompleted = | ||||
|     (pkgJsonUpdater: PackageJsonUpdater, | ||||
|      processingMetadataPerEntryPoint: Map<string, EntryPointProcessingMetadata>, task: Task, | ||||
|      outcome: TaskProcessingOutcome, ): void => { | ||||
|     (pkgJsonUpdater: PackageJsonUpdater, task: Task, outcome: TaskProcessingOutcome): void => { | ||||
|       const {entryPoint, formatPropertiesToMarkAsProcessed, processDts} = task; | ||||
| 
 | ||||
|       if (outcome === TaskProcessingOutcome.Processed) { | ||||
| @ -27,8 +25,6 @@ export const onTaskCompleted = | ||||
|             [...formatPropertiesToMarkAsProcessed]; | ||||
| 
 | ||||
|         if (processDts) { | ||||
|           const processingMeta = processingMetadataPerEntryPoint.get(entryPoint.path) !; | ||||
|           processingMeta.hasProcessedTypings = true; | ||||
|           propsToMarkAsProcessed.push('typings'); | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -16,7 +16,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 {TargetedEntryPointFinder} from './entry_point_finder/targeted_entry_point_finder'; | ||||
| import {AnalyzeEntryPointsFn, CreateCompileFn, EntryPointProcessingMetadata, Executor, Task, TaskProcessingOutcome} from './execution/api'; | ||||
| import {AnalyzeEntryPointsFn, CreateCompileFn, Executor, Task, TaskProcessingOutcome} from './execution/api'; | ||||
| import {AsyncSingleProcessExecutor, SingleProcessExecutor} from './execution/single_process_executor'; | ||||
| import {ConsoleLogger, LogLevel} from './logging/console_logger'; | ||||
| import {Logger} from './logging/logger'; | ||||
| @ -138,7 +138,6 @@ export function mainNgcc( | ||||
|         fileSystem, pkgJsonUpdater, logger, dependencyResolver, config, absBasePath, | ||||
|         targetEntryPointPath, pathMappings, supportedPropertiesToConsider, compileAllFormats); | ||||
| 
 | ||||
|     const processingMetadataPerEntryPoint = new Map<string, EntryPointProcessingMetadata>(); | ||||
|     const unprocessableEntryPointPaths: string[] = []; | ||||
|     const tasks: Task[] = []; | ||||
| 
 | ||||
| @ -165,8 +164,6 @@ export function mainNgcc( | ||||
|         // Only process typings for the first property (if not already processed).
 | ||||
|         processDts = false; | ||||
|       } | ||||
| 
 | ||||
|       processingMetadataPerEntryPoint.set(entryPoint.path, {hasProcessedTypings}); | ||||
|     } | ||||
| 
 | ||||
|     // Check for entry-points for which we could not process any format at all.
 | ||||
| @ -177,7 +174,7 @@ export function mainNgcc( | ||||
|           unprocessableEntryPointPaths.map(path => `\n  - ${path}`).join('')); | ||||
|     } | ||||
| 
 | ||||
|     return {processingMetadataPerEntryPoint, tasks}; | ||||
|     return tasks; | ||||
|   }; | ||||
| 
 | ||||
|   // The function for creating the `compile()` function.
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user