Skip to content

Commit 8919c80

Browse files
devversionpkozlowski-opensource
authored andcommitted
refactor(migrations): speed up code refactoring action for queries (angular#58525)
We were not properly passing around the TCB full program optimization, so TCB generation was done per individual file. This significantly slowed down reference resolution. PR Close angular#58525
1 parent 121b340 commit 8919c80

File tree

2 files changed

+6
-7
lines changed
  • packages

2 files changed

+6
-7
lines changed

packages/compiler-cli/src/ngtsc/typecheck/src/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export class TemplateTypeCheckerImpl implements TemplateTypeChecker {
150150
) {}
151151

152152
getTemplate(component: ts.ClassDeclaration, optimizeFor?: OptimizeFor): TmplAstNode[] | null {
153-
const {data} = this.getLatestComponentState(component);
153+
const {data} = this.getLatestComponentState(component, optimizeFor);
154154
if (data === null) {
155155
return null;
156156
}

packages/core/schematics/migrations/signal-queries-migration/migration.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ export class SignalQueriesMigration extends TsurgeComplexMigration<
104104

105105
// Pre-Analyze the program and get access to the template type checker.
106106
const {templateTypeChecker} = info.ngCompiler['ensureAnalyzed']();
107+
// Generate all type check blocks.
108+
templateTypeChecker.generateAllTypeCheckBlocks();
107109

108110
const {sourceFiles, program} = info;
109111
const checker = program.getTypeChecker();
@@ -205,8 +207,7 @@ export class SignalQueriesMigration extends TsurgeComplexMigration<
205207
// Ignore references to non-query class fields.
206208
if (
207209
this.config.assumeNonBatch &&
208-
descriptor !== null &&
209-
!filteredQueriesForCompilationUnit.has(descriptor.key)
210+
(descriptor === null || !filteredQueriesForCompilationUnit.has(descriptor.key))
210211
) {
211212
return null;
212213
}
@@ -448,8 +449,6 @@ export class SignalQueriesMigration extends TsurgeComplexMigration<
448449
ts.forEachChild(node, queryWholeProgramVisitor);
449450
};
450451

451-
this.config.reportProgressFn?.(40, 'Tracking query declarations..');
452-
453452
for (const sf of info.fullProgramSourceFiles) {
454453
ts.forEachChild(sf, queryWholeProgramVisitor);
455454
}
@@ -493,14 +492,14 @@ export class SignalQueriesMigration extends TsurgeComplexMigration<
493492
isClassWithKnownFields: (clazz) => knownQueries.getQueryFieldsOfClass(clazz) !== undefined,
494493
});
495494

496-
this.config.reportProgressFn?.(70, 'Checking inheritance..');
495+
this.config.reportProgressFn?.(80, 'Checking inheritance..');
497496
groupedAstVisitor.execute();
498497

499498
if (this.config.bestEffortMode) {
500499
filterBestEffortIncompatibilities(knownQueries);
501500
}
502501

503-
this.config.reportProgressFn?.(80, 'Migrating queries..');
502+
this.config.reportProgressFn?.(90, 'Migrating queries..');
504503

505504
// Migrate declarations.
506505
for (const extractedQuery of sourceQueries) {

0 commit comments

Comments
 (0)