You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Migration to Control Flow Syntax Removes CommonModule While Still Needed #59846
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
Yes
Description
When running the ng generate @angular/core:control-flow schematic on a large project, the migration tool incorrectly removes CommonModule from the component's imports: [] array, even though directives or pipes like async, date, and ngTemplateOutlet are still in use. This leads to runtime errors where these directives and pipes are no longer recognized in the template, but not fails the build
Please provide a link to a minimal reproduction of the bug
this bug only related to standalone components (our project is mixed)
I suspect It might related to components were the template isn't changed (meaning already using the new control flow) - but has CommonModule in the imports array - maybe in this edge case, the migration removes the CommonModule without check if other directives are used
Yeah, I suspect if you already have new control flow in, the visitor may skip over checking inside that portion of the template to see if common module symbols are being used.
Activity
JeanMeche commentedon Feb 4, 2025
Hi, we might still need a reproduction to understand how often this problem can arise.
tomer953 commentedon Feb 4, 2025
@JeanMeche please
migrate this, you'll see the error
control-flow-reproduce.mp4
JeanMeche commentedon Feb 4, 2025
Okay so it happens when the only usage is inside another view, here the
@if.tomer953 commentedon Feb 4, 2025
seems you're right...
maybe related to here
angular/packages/core/schematics/ng-generate/control-flow-migration/types.ts
Line 373 in 146ab9a
thePunderWoman commentedon Feb 5, 2025
Yeah, I suspect if you already have new control flow in, the visitor may skip over checking inside that portion of the template to see if common module symbols are being used.
crisbeto commentedon Feb 5, 2025
I think this may have been fixed in a newer version. I just tried it against our unit tests and couldn't reproduce it.
fix(migrations): count used dependencies inside existing control flow
crisbeto commentedon Feb 5, 2025
Ah nevermind, my test wasn't set up correctly. Here's a fix for this issue and one more: #59861.
tomer953 commentedon Feb 5, 2025
Thanks for the quick fix!
Any way to use the fixed code without update our angular version? (Even as a workaround to replace some file)
fix(migrations): count used dependencies inside existing control flow (…
fix(migrations): count used dependencies inside existing control flow (…
angular-automatic-lock-bot commentedon Mar 15, 2025
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.