Skip to content

Commit 125fb77

Browse files
committed
perf(@angular-devkit/build-angular): reduce TypeScript JSDoc parsing in application builder
TypeScript 5.3 provides a new programmatically accessible option on the compiler host object to control the amount of JSDoc parsing that the TypeScript parser will perform. The `tsc` command line tool now uses the `ParseForTypeErrors` value which only parses JSDoc comments that may affect type checking and is considered a good default for tools such as the Angular CLI. The Angular CLI will now attempt to use the `ParseForTypeErrors` value as well when available. Projects will need to use TypeScript 5.3+ for this option to be available. No behavior changes will occur on TypeScript 5.2 projects. This should not only provide a small improvement to build times but also a reduction in overall memory usage.
1 parent 4b3a965 commit 125fb77

File tree

1 file changed

+6
-0
lines changed
  • packages/angular_devkit/build_angular/src/tools/esbuild/angular

1 file changed

+6
-0
lines changed

packages/angular_devkit/build_angular/src/tools/esbuild/angular/angular-host.ts

+6
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ export function createAngularCompilerHost(
4848
): AngularCompilerHost {
4949
// Create TypeScript compiler host
5050
const host: AngularCompilerHost = ts.createIncrementalCompilerHost(compilerOptions);
51+
// Set the parsing mode to the same as TS 5.3 default for tsc. This provides a parse
52+
// performance improvement by skipping non-type related JSDoc parsing.
53+
// NOTE: The check for this enum can be removed when TS 5.3 support is the minimum.
54+
if (ts.JSDocParsingMode) {
55+
host.jsDocParsingMode = ts.JSDocParsingMode.ParseForTypeErrors;
56+
}
5157

5258
// The AOT compiler currently requires this hook to allow for a transformResource hook.
5359
// Once the AOT compiler allows only a transformResource hook, this can be reevaluated.

0 commit comments

Comments
 (0)