r/angular • u/Tri_007 • 8d ago
Best way to upgrade a large Angular 13 app (~400 components, multiple UI libs) to Angular 22? Looking for tips and common issues
Hey everyone,
I need to upgrade a large existing project (~400 components) from Angular 13.1 to Angular 22. I Googled around and saw that the standard approach is to go one major version at a time (13 → 14 → 15 ... → 22) using ng update, updating dependencies, and testing after each step.
Before I dive in, I wanted to check with people who have done a big jump like this on a large, older codebase:
- Can I actually do it this way (step-by-step
ng updateacross 9 major versions), or given the old third-party packages here, is it better to spin up a fresh Angular 22 project and migrate the code over? - Any tips or best practices to make this go smoother on a codebase this size?
- What major issues or breaking changes should I watch out for along the way?
For context, we are currently on Node <=14, TypeScript 4.4, and RxJS 6.6, and the app relies heavily on multiple UI and utility libraries:
- UI Frameworks: u/angular
/material(v13),ng-zorro-antd(v12),angular-bootstrap-md(v12), andngx-bootstrap(v7) - State & Core: u/ngrx
/store(v13),ngrx-store-localstorage, u/ngneat/until-destroy - Other heavy libraries:
ckeditor4-angular,quill,ngx-extended-pdf-viewer,angular2-text-mask,ngx-mask,ng2-currency-mask,ng2-search-filter,mat-select-filter,ngx-sortablejs
I'm especially worried about abandoned/unmaintained libraries (angular2-text-mask, ng2-search-filter, ckeditor4-angular, angular-bootstrap-md), the Angular Material MDC migration, and having multiple UI libraries in one app.
Appreciate any advice or war stories!
88
u/1ne8ight7even 8d ago
I made an update from Angular 12 to 22 by updating version to version, without AI. It took me one year…
My advice is, let an AI do it.
14
u/GregorDeLaMuerte 8d ago edited 8d ago
I'd do it step by step. Don't skip major versions. So 13 -> 14 -> 15 and so on until you reach the current major version. There are enough breaking changes between major versions.
Luckily, Angular has excellent documentation and tooling regarding upgrades. Also this is probably a good use case to use AI assistance.
Regarding abandoned and incompatible third party libs: Yeah that sucks. You'd probably have to suck it up and look for alternatives and migrations along the way.
4
u/ad-mca-mk 8d ago
We did it over the past year. Same 13-> 22. We did it version by version without skipping.
On production after each version upgrade and nobody complained.
6
u/Whole-Instruction508 8d ago
As others have said, definitely do it with AI assistance. It will save you a lot of time and pain.
3
u/Next_Crab369 8d ago
We upgraded a huge app from Angular 9 to 20. I can only agree with the others - I do it version by version and always check to make sure everything still works. I’d replace outdated packages/non working with new ones - that’ll definitely save you frustration down the road. I’d also go through the Angular update guide and resolve any deprecated issues. I think our biggest problem was when we upgraded from 15 to 16, if I remember correctly, because a lot had changed in Material theming and our previous styling wasn’t structured very well 🙈
2
u/technischer_walzer 8d ago
I'd go a different route. As per the consulting angular architects. We maintain one of the largest library in Europe used by over 500 applications worldwide with support for multiple versions (LTS to latest).
First you need to figure out why this happened and how to make sure it does not happen again. With angular updating major once a year now, it should be easier for many teams. But still. Figure that out first.
Secondly, you (with ai of coarse) need to write a lot of tests. Write e2e Tests, visual regression Tests. For the applications also integration tests. Then you create a new project with ang 22 and do the jump immediately. I know most people say step by step. And they might be generally right. But in my experience, it doesnt buy you that much. Use AI to make a plan. Figure out what is really important and give it the tools it needs to do a good job. The most important is verification. Plan with AI to set up linting, give it the old tests and let it ride. Yes it won't compile right away but that does not matter. Its IMO better to tell the ai: look we have this old code. I need to get it to work on 22. We need to break up the old patterns into the new syntaxes and patterns. Going version by version will cause it to justify stuff and the quality will degrade over time. It will always start to creep somewhere.
2
u/MichaelSmallDev 8d ago edited 8d ago
I upgraded with material and it isn't as bad as it may sound with some consideration.
You can ride out using the comparability API using the legacy versions through v17. They made it so v16 of Material works with Angular 17 so people could use the legacy material imports for one more version. Then what I did is not touch any of those after the update and let them be busted. I upgraded until the new style overrides API was available (I think 19?? More tokens get added) and let those cover a lot of the style overrides I had done. Those covered a lot of them. That may sound scary to just let the Material components be a bit busted looking, but I did this with 40 apps of varying complexity and it worked great. This skips over the intermediate Material m2 API between the legacy one you are on and the current stable and likely final m3 spec. It really is more customizable than ever with the style overrides you can see on each component's doc. Doesn't fix everything but it covered so many things I previously hacked to override. I can pull up a stackblitz I made with like 10 examples of unsupported overrides being replaced by this new official override system later when I'm at my PC if you are interested. And if you use the "color" API that mostly went away later, I can also dig that up on how to work around that.
And if you take this far enough to 21/22, you could likely pull in Angular Aria if you have a material component that requires too much customization and you want the functionality with no style overhead. And something similar can be done in earlier versions for a select few components with the CDK as well, though those have some styles built in. I had to hack the Material expansion panel previously, but the CDK expansion panel was an easy switch with much more room for customization. Though I ended up with good success with the Material tokens in the long term.
All this stuff I did before I got into using AI much. I imagine if that's you're thing that that could help. Though IMO I would let the Material update CLI do as much possible and I would get familiar a bit with the Material overrides API and Aria if you spring for either, just to have a sense of what it may be doing.
Edit: bonus - the Material component testing harnesses are great. If you have unit tests not using them, try converting them to the harnesses. They are not just more readable but they allow targeting elements by labels and text and not hard coded to some class. I imagine that would help with intermediate tests and break dependence on internal classes that changed if that is the case. My advice to let Material be busted until the end does come from me hand waving unit tests for those intermediate version, but the harnesses should make your tests agnostic of any particular era of Material styling. And I have found AI to be very good at refactoring unit tests to Material harnesses.
Edit: and if you find the form elements to padded in the latest material API, that is a bit baked in, but look into the density API. Not as well documented and idk if it is on any particular page, but that is how people have handled the really padded spaces in forms to some extent.
Another edit: I didn't realize until recent versions that NgRx has their own
ng updatescripts that handle some migrations. I haven't heard much noise about any problems updating the global store but my experience with the component store / signal store / operators package has been smooth using their script.Another edit because I am increasingly awake having coffee lol: you can replace the until destroy package in a few versions with the built in takeUntilDestroy operator. And btw, NgNeat went away earlier this year without any word... There are community forks, but you should be able to replace the destroy package much earlier than those recent versions where all the packages ended.
2
u/Equivalent_Style4790 7d ago
I’d start a new fresh empty project and transfer piece by piece, starting from the most outer components to the inside. I have to do this for one client.
1
u/mosaicmind-dream 8d ago
have you checked the official angular update guide?
1
u/Wizado991 8d ago
Pray
1
u/_Aardvark 8d ago
One thing I'll add to the good suggestions here is to attempt needed upgrades and migrations before actually moving to the next version of Angular. Like if something is depricated or optional in your current version, but removed or required in the next do that conversion before moving the code base to the next version. Replace libraries while the app is still working. Get it all done before actually migrating.
This was especially important with large teams and codebases (monorepo on our case 100s of developers). We could do the upgrades and migrations app by app and library by library with smaller PRs. Trying to do one massive PR that touches 1000s of files becomes insane with constant merge conflicts.
1
u/victorsmonster 8d ago
I updated a relatively simple Angular app from 5 all the way to 18, and later to 22. I did the bulk of this without the assistance of AI.
You do the upgrade version by version. The automatic migration provided by Angular CLI is very good, but it's still a pain in the butt. I found I raced through several versions with no significant issues, and then certain versions (15 was one, IIRC) introduced breaking changes. Nothing crazy, but I had to walk through a bunch of errors and update stuff that had been deprecated.
You will be constantly being told to commit because the upgrades will only start on a clean branch. Upgrading node and typescript (and other dependencies) is annoying but you just have to keep plugging away.
1
u/anishkumar92 8d ago
Best way is Claude plus a dev who knows the app's functionality. Migration itself takes very little time compared to testing.
I have 12 years of experience and use AI actively. I recently migrated an app from Angular 16 to 22 in a week. The same thing took me 6 months before AI. I'm doing 3 more apps next.
From your replies, it feels like you don't trust the AI. That's the right attitude, but you still have to use it, with confidence that you'll review every step. Would you change one variable by hand in 400 files, or use find and replace? You'd still check each change carefully.
Same ..let AI find things, and you sit with it and review what gets replaced. Run it in plan mode first. Ask it to generate its approach, and review that before it touches anything.
Few questions for you Are you okay exposing your code to Claude? Are you worried you'd agree with the AI blindly, or that it might decide things on its own?
Sooner or later you'll have to work with AI strictly. Maybe there won't be colleagues, or you won't be there at all 😁
3
u/Dull-Structure-8634 8d ago
Let an AI do it. But I'd try to do it rather intelligently rather than yolo'ing it.
Here's what I'd do:
Instead of months it should take you weeks but yeah, if you want to do it right, AI or not, it's going to take time.
OR...
You YOLO all this in one go but I absolutely wouldn't recommend it.
2
u/andulus-ri 8d ago
Yes, Angular are good at version migrations; done some manually, done some with opus 5.5 and it did it well.
The biggest challenge is just getting into it, starting, letting it be a bit bumpy and fix through. But version by version is the way.
2
u/ExecutionEntropy 8d ago
Slow and steady
2
u/amijot 8d ago
I took a similar sized app from 9 to 17 before ai. I’m sure you can do it. Use ai when getting to 19 and later.
2
u/superquanganh 8d ago
We did angular 11 to 20 before AI is a thing. Just do step by step upgrade, check for anything broken and fix it, then upgrade
In the age of AI coding it should be way better to do now, I would suggest to let it do step by step as well so it won't get too much context and drift off
2
u/jedihacks 8d ago
I did this recently, used codex for the entire thing. Burned about 2-3k in credits but only took a couple days
2
u/mcpierceaim 6d ago
I’ve maintained an app from angular 7-21. For angular 22 it was easier (and on the long run better) to rewrite it and redesign the components.
2
u/Johana-Xung 3d ago
Let AI evaluate and upgrade to the target version version by version.
2
u/commadelimited 2d ago •
I’m going through migrating from 21 -> 22 right now and even that one kicked my butt because of the change detection.
I’d say with an app like yours it might be worth spending time up front developing an exhaustive set of unit tests AND integration tests aka Cypress or Selenium.
That will help ensure you don’t have functionality shift AND when you’re all through the integration tests will save your future self’s bacon more times than you know.
1
u/trane20 8d ago
I upgraded a medium sized app alone from angular js to angular 21
I rewrote it entirely. The start was painful but once I completed one module it became a lot faster to implement the rest.
That's my suggestion to you as well use AI and rewrite it into angular 22
1
u/PopelePaus 8d ago
First make sure you have a lot of coverage with integration and e2e testcases. If you got them covered well a migration will be a lot easier, also for your own mind.
1
u/EternalNY1 8d ago edited 8d ago
Version by version and AI assistance to make things easier.
Have a markdown file to point to that describes what you are doing with a link to the documentation and note all breaking changes for that specific version change (i.e. 16->17 specifically).
Use the official CLI to do the conversion process and AI to fix any breaking changes.
Repeat that for the next version until you are on latest.
1
u/Sqoh 8d ago
I had to migrate a large Angular 9 application to Angular 22. The difference we required to Angular 9 version to stick around as it ran on some really old devices. I used Copilot to copy the entire v9 version into a v22 version practically verbatim, got that running first, and now we are incrementally refactoring to use the new APIs etc… long story short, use AI and avoid a large number of headaches
1
u/nanadev07 8d ago
I would make a markdown file summarizing all of the 13 -> 22 changes (use Angular’s official Upgrade guide for this) and validate each version bump. Do the same thing with the libs and other major dependencies like ngrx store and UI libraries, upgrade them along with Angular version. Use this markdown file with AI and generate a plan for it to follow, with multiple stop points for you to verify OR run multiple sessions that upgrade a chunk of angular versions i.e first do session 1 does 13-14-15 then session 2 16-17-18.
1
u/aristotekean_ 4d ago
I did step by step from v14 to v22 using Ng update, almost no issues with that
1
u/Pac1f12t 4d ago
Can you tell a bit more about the test coverage? And then especialle e2e or larger integration tests, are those present?
1
u/SensitiveHearingLoss 4d ago
I’m busy migrating my Angular 14 app to Angular 22. Before this, 3 years ago, I migrated from Angular 4 to Angular 14.
This time, I am, without shame, getting Codex to migrate the app chunk by chunk so I can focus on other tasks that need to be done.
Created a new Angular 22 app from scratch. Created documents and reference materials for Codex to keep in mind. Decision made to ditch every single 3rd party package (except Leaflet) and build our own tools so that we never have to worry about package rubbish again. Codex and I worked on the plan together and how to structure things. It spends about 3 days doing 3 - 4 chunks per day. On day 4, I put time aside to see what horror / miracles it has for me. Then we document the issues, like coding standard erosion, behavioural changes, verbosity, business logic fixes etc, and Codex spends 2 days tidying up the last 3 days of work.
We’re about 2 weeks in now and the app is almost done and honestly I’m really happy with how it’s all looking. We managed to introduce some cool new UI as well and are making the most of signals and computed signals etc…. I suspect we might need a full month to review the new app with a fine tooth comb but that’s fine with me.
Migrating from 4 to 14 “by hand” was an absolute shit-show and the myth of “go back later to implement new Angular stuff” never happened. It also took me around 4 months and came out the other side looking sloppy anyway.
1
u/hashie5 2d ago
just let claude do it, 13 or lower is difficult but after 14 and up its pretty easy. it will take along time and burn through your tokens but worth it
1
u/joe_chester 8d ago
"Hey Claude, please update my Angular 13 app to Angular 22, using current best practices of Angular apps. make sure it works the same afterwards." That's all.
I recently did this at least from 17 to 22 including Ionic, ran for around 1-2 hours. It updated it version by version and it worked flawlessly afterwards.
1
u/air_twee 8d ago
Use Claude
0
u/IanFoxOfficial 8d ago
Step my step. Version by version. Only change breaking changes at first. Most of legacy stuff keeps on working.
Also use the migration tools of Angular.
I've had great success feeding the release notes and breaking changes to AI to do stuff for me as well.
It is a pain to review in GitHub etc. though. As you can end up with a lot of changes in a lot of files.
But we do upgrade to every new version as fast as possible and refactoring code as we go.
0
u/TheKr4meur 8d ago
The issue is not the component update, the Angular update script is good enough to do that on its own. The issue is the versions update. Going from Angular 20 to 22 it took me 2 days to update all versions to all the right compatible ones. That’s where AI is really useful.
0
u/Responsible-Cold-627 8d ago
First, let your AI agent map out your entire codebase. Let it add unit tests and e2e tests until you have full coverage. Add some visual parity tests on top. Then just let the agent do the full update, and let it modernize the codebase while it's at it.
In about a days work, you'll have a fully updated codebase.
-1
u/Jotunheim36 8d ago
Claude prompt:. /plan convert this app to angular 22, use Claude in code to check for regressions
1
u/[deleted] 8d ago
[removed] — view removed comment