mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
fix(compiler-cli): report invalid imports in standalone components during resolve phase (#45827)
The analysis phase of the compiler should operate on individual classes, independently of the analysis of other classes. The validation that `Component.imports` only contains standalone entities or NgModules however did happen during the analysis phase, introducing a dependency on other classes and causing inconsistencies due to ordering and/or asynchronous timing differences. This commit fixes the issue by moving the validation to the resolve phase, which occurs after all classes have been analyzed. Fixes #45819 PR Close #45827
This commit is contained in:
parent
38f2906422
commit
9cfea3d522
1 changed files with 6 additions and 10 deletions
|
|
@ -276,16 +276,6 @@ export class ComponentDecoratorHandler implements
|
|||
}
|
||||
diagnostics.push(...importDiagnostics);
|
||||
}
|
||||
|
||||
const validationDiagnostics =
|
||||
validateStandaloneImports(resolvedImports, rawImports, this.metaReader, this.scopeReader);
|
||||
if (validationDiagnostics.length > 0) {
|
||||
isPoisoned = true;
|
||||
if (diagnostics === undefined) {
|
||||
diagnostics = [];
|
||||
}
|
||||
diagnostics.push(...validationDiagnostics);
|
||||
}
|
||||
}
|
||||
|
||||
let schemas: SchemaMetadata[]|null = null;
|
||||
|
|
@ -801,6 +791,12 @@ export class ComponentDecoratorHandler implements
|
|||
}
|
||||
}
|
||||
|
||||
if (analysis.resolvedImports !== null && analysis.rawImports !== null) {
|
||||
const standaloneDiagnostics = validateStandaloneImports(
|
||||
analysis.resolvedImports, analysis.rawImports, this.metaReader, this.scopeReader);
|
||||
diagnostics.push(...standaloneDiagnostics);
|
||||
}
|
||||
|
||||
if (analysis.providersRequiringFactory !== null &&
|
||||
analysis.meta.providers instanceof WrappedNodeExpr) {
|
||||
const providerDiagnostics = getProviderDiagnostics(
|
||||
|
|
|
|||
Loading…
Reference in a new issue