Skip to content

Commit 9cfea3d

Browse files
JoostKdylhunn
authored andcommitted
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
1 parent 38f2906 commit 9cfea3d

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

  • packages/compiler-cli/src/ngtsc/annotations/component/src

packages/compiler-cli/src/ngtsc/annotations/component/src/handler.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,6 @@ export class ComponentDecoratorHandler implements
276276
}
277277
diagnostics.push(...importDiagnostics);
278278
}
279-
280-
const validationDiagnostics =
281-
validateStandaloneImports(resolvedImports, rawImports, this.metaReader, this.scopeReader);
282-
if (validationDiagnostics.length > 0) {
283-
isPoisoned = true;
284-
if (diagnostics === undefined) {
285-
diagnostics = [];
286-
}
287-
diagnostics.push(...validationDiagnostics);
288-
}
289279
}
290280

291281
let schemas: SchemaMetadata[]|null = null;
@@ -801,6 +791,12 @@ export class ComponentDecoratorHandler implements
801791
}
802792
}
803793

794+
if (analysis.resolvedImports !== null && analysis.rawImports !== null) {
795+
const standaloneDiagnostics = validateStandaloneImports(
796+
analysis.resolvedImports, analysis.rawImports, this.metaReader, this.scopeReader);
797+
diagnostics.push(...standaloneDiagnostics);
798+
}
799+
804800
if (analysis.providersRequiringFactory !== null &&
805801
analysis.meta.providers instanceof WrappedNodeExpr) {
806802
const providerDiagnostics = getProviderDiagnostics(

0 commit comments

Comments
 (0)