Repository navigation
Closed
Labels
area: migrationsIssues related to `ng update`/`ng generate` migrationscore: control flowIssues related to the built-in control flow (@if, @for, @switch)
Milestone
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
Dear Team Angular 🦸♂️
Changing to control flow was the last step of our Angular 17 migration journey. It took us 2 days to migrate over to the "standalone way of doing things" in our 2000+ monorepo.
Once we ran the last schematic to introduce control flow, it changed 730 html files and the build failed.
We took a look at why it was failing. Attaching a zip ball that contains an advanced page and what it looked like before and after we applied the schematic. I recommend opening the files up with a diff tool.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Look at the errors in the attached zip.
Please provide the environment you discovered this bug in (run ng version)
Node : 20.9.0
OS : darwin-arm64
yarn : 1.22.19
@angular/core : 17.0.2
nx : 17.1.1
@nx/js : 17.1.1
@nx/jest : 17.1.1
@nx/linter : 17.1.1
@nx/eslint : 17.1.1
@nx/workspace : 17.1.1
@nx/angular : 17.1.1
@nx/cypress : 17.1.1
@nx/devkit : 17.1.1
@nx/eslint-plugin : 17.1.1
@nx/storybook : 17.1.1
@nrwl/tao : 17.1.1
@nx/web : 17.1.1
@nx/webpack : 17.1.1
typescript : 5.2.2
---------------------------------------
Community plugins:
@compodoc/compodoc : 1.1.22
@fortawesome/angular-fontawesome : 0.14.0
@jscutlery/semver : 4.0.0
@ng-bootstrap/ng-bootstrap : 15.1.2
@ngneat/transloco : 6.0.0
@ngrx/component : 16.3.0
@ngrx/component-store : 16.3.0
@ngrx/data : 16.3.0
@ngrx/effects : 16.3.0
@ngrx/entity : 16.3.0
@ngrx/router-store : 16.3.0
@ngrx/schematics : 16.3.0
@ngrx/store : 16.3.0
@ngrx/store-devtools : 16.3.0
@storybook/angular : 7.5.3
angular-calendar : 0.31.0
Anything else?
No response
Metadata
Metadata
Assignees
Labels
area: migrationsIssues related to `ng update`/`ng generate` migrationscore: control flowIssues related to the built-in control flow (@if, @for, @switch)
Activity
jessicajaniuk commentedon Nov 15, 2023
@bjornharvold I appreciate the report, but can you upload your migrated templates to a github repo for us to look at? A zip file is not safe for us to open. We're also about to release our new patch version, which will have updated fixes. So it's likely issues may have been resolved already.
jessicajaniuk commentedon Nov 15, 2023
17.0.3 is out now, which included some migration fixes. Let us know if you're still seeing issues. Ideally provide minimal reproductions for us to work with.
bjornharvold commentedon Nov 16, 2023
Hi @jessicajaniuk
Having the same issues. Not sure how a minimal reproduction would help. I would create a new project and put the html file I already shared with you in app.component.html and you would run the migration schematic which would produce the after.txt file I also shared with you.
I think more interestingly is to look at the files I shared in a diff viewer to make out in which cases the schematic fails.
Here's the result after I upgraded to 17.0.3 and ran the schematic on the previous before.txt I already shared. It's clear the schematic gets confused with multi-line elements for example.
FYI My entire project uses the default prettier setting of 80 character print width and I would assume many other projects do this too.
after-17.0.3.txt
Cheers,
Bjorn
jessicajaniuk commentedon Nov 16, 2023
@bjornharvold Hi Bjorn. I know you sent us a big zip file, but for security reasons we are not allowed to open zip files. The minimal reproduction is intended to help us isolate the migrated issues. You can use gist, stackblitz, and or a github repository to upload src files. You can even use a comment with 3 backticks to share code snippets. For example:
bjornharvold commentedon Nov 17, 2023
Ah, I see. I didn't know. I first tried pasting it here but the component is way too large.
Here's a gist of the diff between before and after:
https://gist.github.com/bjornharvold/fa713051c0f87caf46bc9bdddddbfd53
jessicajaniuk commentedon Nov 17, 2023
@bjornharvold Thank you! I'll take a look.
jessicajaniuk commentedon Nov 17, 2023
@bjornharvold OK, I can tell some of the issues you're seeing are pre-17.0.3 in this example due to presence of placeholder strings (like
#showLoadingIndicator|in the first example) that have since been resolved. I've also added individual test cases for some of theng-containerdiffs you're seeing here and they do pass. So, the suspicion I have is that your template is just so large that the offset is off by one somewhere, which gets worse as it moves down the file. Without the full original template to run, it'll be harder for me to debug. Can you create a gist of the pre-transformed template? I can try running it through here and that'll help me isolate where that offset shift is happening.jessicajaniuk commentedon Nov 17, 2023
@bjornharvold I was incorrect! I've been able to replicate the problem locally. It looks like it's specifically an issue with
if then elseusages. Your template migrates perfectly without thethenclause at the start. That's a bug I can definitely fix. Thanks for reporting this! I will have a fix out shortly.marcusrettig commentedon Nov 17, 2023
We had an issue with nested
[ngSwitch]cases, e.g.produces the following output
Other than that, version 17.0.3 worked very well for most of our code.
jessicajaniuk commentedon Nov 17, 2023
@marcusrettig Can you file a separate bug for that one? That'd be helpful for tracking purposes.
UPDATE: I created #53009 to track it. Thanks!
jessicajaniuk commentedon Nov 17, 2023
@bjornharvold #53006 fixes this issue. Thanks again for reporting it!
fix(migrations): Fixes control flow migration if then else case
bjornharvold commentedon Nov 18, 2023
Thanks for the super fast response here @jessicajaniuk
fix(migrations): Fixes control flow migration if then else case (#53006)
bjornharvold commentedon Nov 21, 2023
I can confirm that that v17.0.4 fixes all past issues. Thank you. It asked if I wanted to format my code and I initially said yes. This made me wait for 10 hours without anything happening even though node was at 100% CPU the whole time. So I started over again and declined the formatting and that worked without issues. Ran the code through prettier manually instead. Will not create a ticket for the wait time. My Angular 17 migration is officially complete 🍿🍺
jessicajaniuk commentedon Nov 21, 2023
Thanks for the heads up on the formatting. I'll keep an eye on that process.
angular-automatic-lock-bot commentedon Dec 22, 2023
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.
fix(migrations): Fixes control flow migration if then else case (angu…
fix(migrations): Fixes control flow migration if then else case (angu…
fix(migrations): Fixes control flow migration if then else case (angu…
fix(migrations): Fixes control flow migration if then else case (angu…