Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng serve doesn't automatically recover if a component provided via NgModule disappears and then reappears #27698

Open
sod opened this issue May 23, 2024 · 2 comments
Labels
area: angular/build freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix

Comments

@sod
Copy link

sod commented May 23, 2024

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 serve doesn'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:

CleanShot.2024-05-23.at.15.52.42-converted.mp4

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
@sod
Copy link
Author

sod commented May 23, 2024

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:

CleanShot.2024-05-23.at.16.19.34.mp4

@sod
Copy link
Author

sod commented May 23, 2024

I remember there were a bunch of PRs like #20236 from @clydin that once tried to tackle this problem (recheck dependands in watch mode)

@alan-agius4 alan-agius4 added severity3: broken area: angular/build type: bug/fix freq1: low Only reported by a handful of users who observe it rarely labels May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: angular/build freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Projects
None yet
Development

No branches or pull requests

2 participants