`ng serve` doesn't automatically recover if a component provided via NgModule disappears and then reappears
Command
serve (esbuild application builder)
Is this a regression?
I'm pretty sure not a recent regression. This behavior was also lately in the webpack build
Description
The title:
ng servedoesn't automatically recover if a component provided via NgModule disappears and then reappears
This behavior means that if you switch your working branch and someone removed or moved a component from one NgModule to another, you must restart ng serve to recover when you switch back or you are stuck with a bunch of errors of [ERROR] NG8001: 'app-foo' is not a known element
Minimal Reproduction
git clone [email protected]:sod/v18-ngmodule.git
v18-ngmodule
yarn install
ng serve
then remove the FooComponent export in the Shared1Module and add it back in. See how the error:
✘ [ERROR] NG8001: 'app-foo' is not a known element:
Won't go away until you change the component where <app-foo> is actively used.
Video of reproduction:
https://github.com/angular/angular-cli/assets/905328/69be16cf-0f29-4936-adb8-3dfab20a86a4
Your Environment
Angular CLI: 18.0.0
Node: 20.11.1
Package Manager: yarn 1.22.19
OS: darwin arm64
Angular: 18.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1800.0
@angular-devkit/build-angular 18.0.0
@angular-devkit/core 18.0.0
@angular-devkit/schematics 18.0.0
@schematics/angular 18.0.0
rxjs 7.8.1
typescript 5.4.5
zone.js 0.14.6
In a similar fashion this also affects standalone components. E.g. if you change the selector of a standalone component and then change it back, the consumers of that given standalone component wont recover automatically.
See this reproduction:
https://github.com/angular/angular-cli/assets/905328/8dc946eb-ce43-4d7b-9d2e-e48dd9e7e229
I remember there were a bunch of PRs like https://github.com/angular/angular-cli/pull/20236 from @clydin that once tried to tackle this problem (recheck dependands in watch mode)
Not sure what you changed, but we are on version 18.2.0 for a while now, and that compiler feels rock solid. It even recovers from switches between rather big changes. 🚀
So I'll close this.
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.