feat(ivy): skip analysis of unchanged components (#30238)
Now that the dependent files and compilation scopes are being tracked in the incremental state, we can skip analysing and emitting source files if none of their dependent files have changed since the last compile. The computation of what files (and their dependencies) are unchanged is computed during reconciliation. This commit also removes the previous emission skipping logic, since this approach covers those cases already. PR Close #30238
This commit is contained in:

committed by
Alex Rickabaugh

parent
411524d341
commit
fbff03b476
@ -110,7 +110,6 @@ export interface AnalysisOutput<A> {
|
||||
diagnostics?: ts.Diagnostic[];
|
||||
factorySymbolName?: string;
|
||||
typeCheck?: boolean;
|
||||
allowSkipAnalysisAndEmit?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -172,11 +172,9 @@ export class IvyCompilation {
|
||||
private analyze(sf: ts.SourceFile, preanalyze: true): Promise<void>|undefined;
|
||||
private analyze(sf: ts.SourceFile, preanalyze: boolean): Promise<void>|undefined {
|
||||
const promises: Promise<void>[] = [];
|
||||
|
||||
// This flag begins as true for the file. If even one handler is matched and does not explicitly
|
||||
// state that analysis/emit can be skipped, then the flag will be set to false.
|
||||
let allowSkipAnalysisAndEmit = true;
|
||||
|
||||
if (this.incrementalState.safeToSkip(sf)) {
|
||||
return;
|
||||
}
|
||||
const analyzeClass = (node: ClassDeclaration): void => {
|
||||
const ivyClass = this.detectHandlersForClass(node);
|
||||
|
||||
@ -203,12 +201,6 @@ export class IvyCompilation {
|
||||
this.sourceToFactorySymbols.has(sf.fileName)) {
|
||||
this.sourceToFactorySymbols.get(sf.fileName) !.add(match.analyzed.factorySymbolName);
|
||||
}
|
||||
|
||||
// Update the allowSkipAnalysisAndEmit flag - it will only remain true if match.analyzed
|
||||
// also explicitly specifies a value of true for the flag.
|
||||
allowSkipAnalysisAndEmit =
|
||||
allowSkipAnalysisAndEmit && (!!match.analyzed.allowSkipAnalysisAndEmit);
|
||||
|
||||
} catch (err) {
|
||||
if (err instanceof FatalDiagnosticError) {
|
||||
this._diagnostics.push(err.toDiagnostic());
|
||||
@ -251,19 +243,9 @@ export class IvyCompilation {
|
||||
|
||||
visit(sf);
|
||||
|
||||
const updateIncrementalState = () => {
|
||||
if (allowSkipAnalysisAndEmit) {
|
||||
this.incrementalState.markFileAsSafeToSkipEmitIfUnchanged(sf);
|
||||
}
|
||||
};
|
||||
|
||||
if (preanalyze && promises.length > 0) {
|
||||
return Promise.all(promises).then(() => {
|
||||
updateIncrementalState();
|
||||
return undefined;
|
||||
});
|
||||
return Promise.all(promises).then(() => undefined);
|
||||
} else {
|
||||
updateIncrementalState();
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user