Last updated:
17 min readSolutions
How we upgraded Angular 12 to 21: Modernizing a seven-year enterprise codebase without starting over
Team Lead Mykola Voievudskyi shares what broke, what worked, and what it really takes to modernize an enterprise Angular application.

Upgrading an enterprise application across nine major Angular versions sounds like the kind of project that ends in a rewrite. It didn’t.
In this article, we break down how our team migrated a 200,000-line production platform, upgrading Angular 12 to 21 while continuing to ship features, avoiding a rewrite, and modernizing the application along the way. You’ll see what actually broke, what the Angular CLI handled for us, where AI genuinely helped, and the lessons we’d carry into the next migration.
The story comes directly from Mykola Voievudskyi, Senior Full-Stack Developer and Team Lead at Brainence, who planned and led the migration from the first version bump to the last.
Background and experience
Eight-plus years in .NET, six of them in Angular and TypeScript, building scalable enterprise systems with integrations across Linnworks, logistics, shipping, tracking, and payment platforms like Payoneer. He’s led modernization work before this one too, including a migration from Windows to Linux containers and earlier core framework upgrades.
Led the Angular migration on the data collection platform from the first version bump to the last, and what follows is his account of how it went.
Mykola Voievudskyi, Senior Full-Stack Developer, Team Lead at the DDC
The project behind the migration
Our client is a consulting group based in the Netherlands that helps regional, national, and international organizations manage crisis response and civil protection. For years, many of their processes relied on paper forms, spreadsheets, and disconnected reporting, making it difficult to collect reliable data or build a complete picture of incidents and training outcomes.
Since 2019, we’ve been building the cloud platform that replaced those manual workflows. What started as an MVP has grown into a business-critical application used by organizations across Europe. Today, it includes an administration portal for managing users and permissions, a data collection environment for incident reports and evaluations, and a real-time reporting dashboard that provides GDPR-compliant insights.
As the product evolved, so did the codebase. New features, integrations, reporting capabilities, and customer requirements accumulated over seven years without ever pausing development. By the time we started planning the modernization, the application had grown to more than 200,000 lines of code, with roughly 570 Angular components, 16 lazy-loaded feature modules, and over 100 AG Grid-based data tables.
At the same time, the technology stack had begun to lag behind. The application was still running on Angular 12, while the framework had already reached Angular 21. That gap represented much more than version numbers. It meant several generations of architectural changes, including Ivy replacing View Engine, standalone components replacing NgModules, signals, the new control flow syntax, an entirely new build pipeline, plus major upgrades to TypeScript, Node.js, Angular Material, AG Grid, and numerous third-party libraries.
The obvious question was whether it made more sense to rewrite the application from scratch or modernize the one we already had.
Why not just rewrite?
“Just rewrite it” came up, of course. It always does.
We considered it, then quickly ruled it out. An application of this size carries years of business logic, much of it proven in production and documented nowhere except the code itself. Starting over would have meant months of frozen feature development, re-testing every workflow from scratch, and inevitably reintroducing bugs we’d already spent years fixing.
Upgrading in place let us keep delivering new functionality while preserving the parts of the system we already trusted.
The strategy was deliberately simple: upgrade one major version at a time, keep the application deployable at every step, and never let the migration bring product development to a halt.
Upgrading Angular, one major version at a time
Angular’s ng update only upgrades one major version at a time. There are no shortcuts from Angular 12 to Angular 21. The path looks like this:
12 → 13 → 14 → 15 → 16 → 17 → 18 → 19 → 20 → 21
Ten upgrades in total. Each release introduces its own breaking changes, dependency updates, and compatibility issues. We treated every version as a project of its own: update the framework, resolve what broke, get the build green, commit, and only then move to the next step.
The process is slower than it might seem, but it pays off. Whenever something failed, we knew exactly which version had introduced the problem because only one variable had changed. That made debugging manageable instead of overwhelming.
Here’s how the core technology stack changed by the end of the migration:
| Piece | From | To |
|---|---|---|
| Angular | 12.2 | 21.2 |
| Angular Material | 12.2 | 21.2 |
| AG Grid | 29.3 | 35.2 |
| TypeScript | 4.2 | 5.9 |
| RxJS | 6.5 | 7.8 |
| Node.js | 14.15 | 22.16 |
| Build system | webpack | esbuild (application builder) |
Dead dependencies stop you before you start
Before the first ng update can succeed, you have to deal with your dependency list. Ours contained several packages that had long since been abandoned: ng-pick-datetime (last published in 2018), mat-virtual-table, and several View Engine-only libraries, including ngx-autosize, ngx-embed-video, and ngx-material-timepicker, none of which would compile on a modern Angular version.
Even a single outdated package can block the entire upgrade path, so this wasn’t something we could postpone. We audited every dependency, removed libraries that were no longer used — some had been imported once and never referenced again — and replaced those that still served a purpose.
Doing that work upfront meant the migration itself wasn’t repeatedly interrupted by unmaintained third-party code.
How Angular Material slowed the migration down
The most time-consuming part of the migration was Angular Material’s transition to MDC. It happened in two stages, and neither was particularly exciting.
In Angular 15, the migration schematics renamed every Material import to its MatLegacy* equivalent — 226 files in total — allowing the application to keep its existing appearance while the new components matured. In Angular 17, we reversed the process, migrating roughly 224 files back to the MDC components and updating the theming API along the way.
- The renames were mechanical. What hurt were two failures with no error message attached.
- The dialogs lost their padding. MDC removed the default 24-pixel padding, leaving content flush against the dialog edge. The application compiled without issue, but the interface was visibly wrong. A single global rule targeting the new surface class restored the expected layout.
- Old .mat-* CSS stopped matching. MDC introduced new DOM structures and .mat-mdc-* class names, which meant our existing .mat-* overrides still compiled but no longer matched anything. Styling quietly disappeared in isolated parts of the application, with no warning from the framework.
That was the lesson from this stage of the migration: don’t rely solely on a successful build. Changes to Angular Material often require a thorough visual review because many UI regressions won’t appear in compiler output.
How Ivy forced us to update legacy libraries
Angular 16 removed ngcc, the compatibility compiler that translated View Engine libraries into Ivy at build time. From that point on, every dependency had to provide native Ivy support. If a library hadn’t been updated, it simply couldn’t be part of the application anymore.
For us, that meant upgrading several core dependencies, including our toast notifications, input masking, and translation libraries. None of those changes were particularly difficult on their own, but each newer version introduced small API changes that had to be addressed before we could move on.
It was another reminder that framework upgrades rarely happen in isolation. Moving Angular from 12 to 21 meant bringing the rest of the dependency tree with it.
Upgrading AG Grid across six major Angular versions
Upgrading Angular wasn’t the only migration running in parallel. We also moved AG Grid from version 29 to 35, a change that affected roughly 64 components across the application.
Several familiar APIs had changed. setColumnDefs() and setRowData() were consolidated into updateGridOptions(), ColumnApi was merged into the main Grid API, filter lookups became asynchronous, and row selection moved from a simple string to a configuration object.
// Before (v29)
this.gridApi.setColumnDefs(cols);
// After (v35)
this.gridApi.updateGridOptions({ columnDefs: cols });
The theming model changed just as significantly. Instead of importing a stylesheet and applying an ag-theme-alpine class, AG Grid now generates themes through themeAlpine.withParams().
Rather than updating more than 60 components individually, we centralized everything — theme configuration, default column definitions, locale settings, and shared grid options — into a single GridConfigService.
That turned out to be one of the best architectural decisions we made during the migration. The next time AG Grid changes its API, we’ll update one service instead of dozens of components.
Bringing TypeScript up to date
Alongside the framework upgrade, we moved TypeScript from 4.2 to 5.9. Compared with the Angular migration, this part was relatively straightforward. Most changes were small but persistent: stricter enum literal assignments, the distinction between boxed Number and primitive number, tighter Subject typing, and dozens of similar compiler checks introduced over several releases.
None of these changes was especially difficult to resolve on its own. Together, though, they reflected seven versions of the language becoming progressively stricter, and updating the codebase meant addressing all of those improvements at once.
Switching from webpack to esbuild
If we were to repeat this migration, this is one change we’d make as early as possible. Starting with Angular 20, the framework adopts the esbuild-based application builder, replacing webpack with a faster build pipeline powered by esbuild and Vite.
The migration came with one notable compatibility issue. The new builder uses “moduleResolution”: “bundler”, which changes how namespace imports are resolved and broke a pattern used throughout our codebase.
// Broke under bundler resolution
import * as moment from ‘moment’;
// Fixed
import moment from ‘moment’;
Updating that pattern affected 67 files, along with integrations using JSZip and our HTML-to-PDF library. The fixes themselves were straightforward and took about a day.
The performance improvements, however, were immediate. Rebuilds became noticeably faster, the development server started in a fraction of the time, and CI pipelines finished sooner, which meant quicker feedback on pull requests and faster deployments.
Individually, shaving a few seconds off every rebuild doesn’t sound significant. Across every developer, every save, and every CI run, those seconds add up quickly. Of all the changes we made during the migration, switching to the new build system delivered some of the most tangible day-to-day improvements.
Going fully standalone
Once the framework was up to date, we used the opportunity to complete Angular’s transition to standalone APIs. We converted all 572 components, directives, and pipes, replaced more than 16 feature NgModules with .routes.ts files, and removed AppModule, SharedModule, and AppRoutingModule entirely, consolidating their providers into a single bootstrapApplication() call. By the end of the migration, there wasn’t a single @NgModule left in the application.
Angular’s standalone schematic (ng g @angular/core:standalone) handled most of the mechanical work. The remaining effort came from edge cases that required manual investigation.
One of them involved ngx-translate. With standalone providers, the translation loader must be registered inside provideTranslateService({ loader: … }). Registering it as a top-level provider compiles without errors, but translations never load, leaving every label in the application empty.
It’s a good example of the kind of issue automated migrations can’t catch. The code compiles successfully, but only thorough testing reveals that something isn’t working.
The CLI did most of the heavy lifting
None of the above would have been survivable by hand, and the reason it didn’t have to be is the Angular CLI. ng update is not just a version bumper: for every hop it rewrites package.json, resolves the peer-dependency graph, and then runs that release’s migration schematics — code-mods written by the Angular team that rewrite your source for the new version. A serious fraction of each upgrade happened while we watched.
A sample of what the schematics handled, and at what scale:
- Both Material MDC rename passes — 226 files onto the legacy aliases, ~224 back off them
- HttpClientModule → provideHttpClient() across 9 files, and the move onto the esbuild builder — each a single command
- The standalone conversion — all 572 components, with their imports arrays filled in
- *ngIf / *ngFor → @if / @for in 157 templates
- Constructor injection → inject() in 664 files
- @Input() / @Output() / @ViewChild → input() / output() / viewChild(), with outputs and queries reaching 100%
- Self-closing tags (1,219 across 360 files) and unused-import cleanup
The caveat: schematics do the mechanical 90% and none of the final 10%. The inject() migration left nine child classes with broken super() calls. The signal-input migration deliberately skipped 113 inputs that get mutated at runtime — those need a real refactor, not a code-mod. The prune-modules pass removed nothing at all, because every module still carried providers only a human could relocate. The pattern held every time: the schematic clears the boring thousand so your attention lands on the awkward handful.
Where no schematic existed, we wrote our own scripts. That’s how takeUntilDestroyed() reached 1,869 subscription sites across 396 files, ngClass fell from 883 uses to 15, and a never-completing new Observable() got replaced by EMPTY in 290 places across 117 files. About to make the same change more than a few dozen times? Stop typing and write the code-mod.
Where AI actually helped to upgrade Angular from 12 to 21
AI deserves its own section because it was part of the migration from start to finish. At the same time, it’s easy to overstate its role. Many write-ups either present AI as the solution to everything or don’t mention it at all. Our experience landed somewhere in between.
It proved most valuable for well-defined, verifiable tasks: generating one-off scripts to update patterns across hundreds of files, finding issues the compiler couldn’t detect — such as obsolete .mat-* selectors — drafting GridConfigService, translating deprecated AG Grid APIs to their newer equivalents, or explaining breaking changes faster than digging through multiple changelogs. For repetitive work with a clear expected outcome, it saved a considerable amount of time.
What it couldn’t do was replace engineering judgment. Deciding on the upgrade strategy, choosing which deprecated libraries to remove or replace, understanding why dialog padding disappeared, determining which of the 113 mutable inputs could safely be migrated, and verifying that every batch of changes behaved correctly all remained human responsibilities.
We approached AI the same way we’d work with a capable junior engineer: give it a well-scoped task, review everything it produces, and never merge changes without verification. Used that way, it became a genuine productivity multiplier. Left to solve broad, loosely defined problems on its own, it could just as easily generate hundreds of incorrect changes as helpful ones.
The bugs the migration uncovered
One unexpected benefit of the migration was that it exposed issues that had been hiding in the codebase for years. As the framework, compiler, and libraries became stricter, they surfaced bugs that had previously gone unnoticed.
Among them were:
- A translation race condition. A shared helper called translateService.get().subscribe() as if it were synchronous. It happened to work because translations loaded during startup, but it also leaked a subscription on every call. Replacing it with the synchronous .instant() API fixed 167 call sites at once.
- Observable memory leaks. We found 290 instances of new Observable() that never completed, creating unnecessary subscriptions.
- Mutated inputs. Several components modified their @Input() objects directly, a pattern that newer Angular change detection no longer tolerates.
- A DateAdapter timezone bug. An unintended UTC conversion shifted weekday names by one day, causing calendar views to start on the wrong day of the week.
- Peer dependency surprises. intl-tel-input version 26 renamed its CSS classes, breaking the styling of every phone input, so we pinned it back to version 19. We also discovered that a phone-number library we’d removed as “unused” was still required as a runtime peer dependency and had to be restored.
Like many large migrations, this one became an opportunity to improve more than compatibility. It also helped us identify and eliminate issues that had quietly existed in production for years.
Lessons from upgrading nine Angular versions
Looking back, a few decisions made the migration significantly smoother. If you’re planning a similar upgrade, these are the lessons we’d carry into the next one:
- Upgrade one major version at a time. Keep the build green after every step so that when something breaks, you know exactly which version introduced it.
- Deal with outdated dependencies first. A single abandoned package can block the entire upgrade path.
- Centralize third-party configuration. Our GridConfigService turned what could have been changes across 64 components into a single update.
- Use the official migration schematics, but expect to finish the job yourself. They automate most of the work, but the final edge cases still require engineering judgment.
- Automate repetitive changes. If you’re about to make the same edit dozens of times, write a code-mod instead of editing files by hand.
- Delegate mechanical work, not decision-making. Whether it’s Angular schematics, custom scripts, or AI tools, automation accelerates execution — it doesn’t replace verification.
- Use the migration to reduce technical debt. We didn’t just upgrade Angular. We removed the last @NgModule, adopted standalone APIs and signals, and reduced the main bundle size by 65% through lazy loading.
The outcome of the migration
By the end of the migration, the application was running on Angular 21.2, Node.js 22, TypeScript 5.9, AG Grid 35, and Angular’s modern esbuild-based build system. It had fully adopted standalone APIs, signals, and the new control flow syntax—all without a rewrite or a prolonged feature freeze.
Upgrading across nine major Angular versions is a significant undertaking, but it doesn’t have to become a complete rebuild. Taking the migration one version at a time, keeping the application deployable throughout, and automating repetitive work wherever possible made the process predictable and manageable.
That, ultimately, was the biggest lesson from the project: with the right strategy, even a seven-year-old enterprise application can evolve alongside the framework it depends on.
Planning a modernization project?
Framework upgrades are rarely just about moving to the latest version. They often involve untangling years of technical debt, replacing outdated dependencies, modernizing architecture, and doing it all without disrupting product delivery.
That’s the kind of work we help teams with at Brainence.
Whether you’re planning an Angular migration, modernizing a legacy application, or scaling an existing product, we can help with:
- Framework and technology upgrades without lengthy feature freezes or risky rewrites.
- Legacy application modernization, including architecture improvements, dependency upgrades, and technical debt reduction.
- Custom software development for complex web applications, SaaS platforms, and enterprise systems.
- Dedicated engineering teams that integrate with your in-house developers to accelerate delivery.
- Performance optimization through modern tooling, architecture, and build pipelines.
- Long-term product development, supporting software through years of growth rather than one-off projects.
Over the past ten years, we’ve helped 80+ companies modernize business-critical software, extend existing platforms, and build new digital products across industries, including healthcare, retail, logistics, e-commerce, construction, and travel.
If you’re evaluating a framework upgrade or wondering where to start with modernizing your application, we’d be happy to discuss the approach that best fits your product.







