angular-cn/packages/compiler-cli/ngcc/test/writing
JoostK f0688b4d18 perf(ngcc): introduce cache for sharing data across entry-points (#38840)
ngcc creates typically two `ts.Program` instances for each entry-point,
one for processing sources and another one for processing the typings.
The creation of these programs is somewhat expensive, as it concerns
module resolution and parsing of source files.

This commit implements several layers of caching to optimize the
creation of programs:

1. A shared module resolution cache across all entry-points within a
   single invocation of ngcc. Both the sources and typings program
   benefit from this cache.
2. Sharing the parsed `ts.SourceFile` for a single entry-point between
   the sources and typings program.
3. Sharing parsed `ts.SourceFile`s of TypeScript's default libraries
   across all entry-points within a single invocation. Some of these
   default library typings are large and therefore expensive to parse,
   so sharing the parsed source files across all entry-points offers
   a significant performance improvement.

Using a bare CLI app created using `ng new` + `ng add @angular/material`,
the above changes offer a 3-4x improvement in ngcc's processing time
when running synchronously and ~2x improvement for asynchronous runs.

PR Close #38840
2020-09-15 11:23:04 -07:00
..
cleaning build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
in_place_file_writer_spec.ts docs(ngcc): add additional next steps to an error (#37672) 2020-06-25 11:37:43 -07:00
new_entry_point_file_writer_spec.ts perf(ngcc): introduce cache for sharing data across entry-points (#38840) 2020-09-15 11:23:04 -07:00
package_json_updater_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00