-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: short-circuit ngcc processing across entry-points
This commit introduces a cache of which entry-points have already been processed by ngcc that is used across entry-points, to avoid the overhead of invoking ngcc repeatedly for all entry-points.
- Loading branch information
Showing
5 changed files
with
46 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Registers the paths to package.json files of libraries that have been processed by ngcc. This | ||
* cache is reused across all entry-points of a package, so module requests across the entry-points | ||
* can determine whether invoking ngcc is necessary. | ||
* | ||
* The cost of invoking ngcc for an entry-point that has already been invoked is limited due to | ||
* a fast path in ngcc, however even in this fast-path does ngcc scan the entry-point to determine | ||
* if all dependencies have been processed. This cache allows to avoid that work, as entry-points | ||
* are processed in batches during which the `node_modules` directory is not mutated. | ||
*/ | ||
export class NgccProcessingCache { | ||
private readonly processedModules = new Set<string>(); | ||
|
||
hasProcessed(packageJsonPath: string): boolean { | ||
return this.processedModules.has(packageJsonPath); | ||
} | ||
|
||
markProcessed(packageJsonPath: string): void { | ||
this.processedModules.add(packageJsonPath); | ||
} | ||
|
||
clear(): void { | ||
this.processedModules.clear(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters