Repository navigation
Description
Which @angular/* package(s) are the source of the bug?
compiler
Is this a regression?
Yes
Description
If an NgModule includes itself as an import, the compiler gets a stack overflow in compiler-cli/src/ngtsc/scope/src/local.ts
import {NgModule} from '@angular/core';
@NgModule({
imports: [AppModule],
})
export class AppModule {}Similarly, if there is a circular import:
import {NgModule} from '@angular/core';
@NgModule({
imports: [AppModule2],
})
export class AppModule1 {}
@NgModule({
imports: [AppModule1],
})
export class AppModule2 {}I was able to reproduce this internally with an ng_module build rule, and also in the angular.dev playground. I've given the stack trace and information from the angular.dev playground.
I would expect a diagnostic that circular dependencies are not allowed.
Please provide a link to a minimal reproduction of the bug
https://angular.dev/playground
Please provide the exception or error you saw
✘ [ERROR] Angular compilation initialization failed. [plugin angular-compiler]
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4358:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4224:32
getExportedScope@file:///home/angular/node_modules/@angular/compiler-cli/bundles/chunk-7SQLBOCA.js:4367:19
getScopeOfModuleReference@file:///home/angular/node_modules/...
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 18.1.3
Node: 18.20.3
Package Manager: npm 10.2.3
OS: linux x64
Angular: 18.1.2
... animations, cdk, common, compiler, compiler-cli, core, forms
... material, platform-browser
Package Version
@angular-devkit/architect 0.1801.3
@angular-devkit/core 18.1.3
@angular-devkit/schematics 18.1.3
@angular/build 18.1.3
@angular/cli 18.1.3
@schematics/angular 18.1.3
rxjs 7.8.1
typescript 5.5.4
Anything else?
No response
Activity
JoostK commentedon Oct 16, 2024
This should be pretty straightforward to resolve, ideally be reporting an error.
fix(compiler-cli): report when NgModule imports or exports itself (#5…
fix(compiler-cli): report when NgModule imports or exports itself (an…
angular-automatic-lock-bot commentedon Nov 18, 2024
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.