Journal

Migrate an Angular project: approach, testing, and pitfalls

An Angular project can usually be migrated step by step. This article covers prerequisites, the Standalone schematic, the build system change, tests, and common mistakes.

Automatically translated from DE. Read original

A person calmly climbs a clearly structured stone staircase, one step at a time, one hand on the handrail.
One step at a time, on solid ground. AI-generated illustration.

The safest way to migrate an existing Angular project is in small, individually testable steps rather than one major overhaul. The Angular CLI provides schematics for this, automating much of the work. This article shows what prerequisites you should create, how the move to Standalone components and the new build system works, and where things typically get stuck in practice.

The essentials at a glance

  • Proceed step by step: one change, tests, commit per step.
  • Standalone components and the new build system are two separate migrations.
  • The old webpack-based build system is outdated.
  • The Standalone schematic does not replace verification of the unit tests.

How can you migrate an Angular project without rewriting everything?

Usually not by rewriting, but by modernizing the existing project. The Angular CLI provides schematics, i.e. automatic transformations that adapt code and configuration to new conventions. You start them with ng update or with a targeted migration command.

With a big-bang approach, you switch everything over in one go. That saves coordination, but it ties up the team for a long time and makes errors harder to assign. With an incremental approach, also called baby steps, you migrate parts of the application one after another, and the application remains runnable and releasable in between.

CriterionBig BangBaby-Steps
Approacheverything in one goone area or step after another
Troubleshootingdifficult, many changes at onceeasy, small changes
Intermediate deliveryoften blockedstill possible

For production applications under active development, the step-by-step approach is usually the better choice. A practical report on Standalone migration without big bangalso describes what this looks like.

What prerequisites should the project meet before starting?

Before you migrate an Angular project, you need a safety net. That means a clean Git state with no open changes and a test suite that passes cleanly beforehand. Without this foundation, after the migration you will not know whether an error came from the migration or was already there.

Also check your dependencies. Third-party libraries, UI kits, and your own packages must match the target version, otherwise ng update package resolution alone may fail. If a library is no longer maintained, plan a replacement early.

Move through version jumps one by one, not several major versions at once. That keeps the changes manageable, and the CLI guidance matches the current state.

Checklist before starting:

  • working tree clean, dedicated migration branch created
  • build and tests run without errors in the starting state
  • dependencies checked for compatibility with the target version
  • responsibilities and time window clarified within the team
  • rollback path defined: each step its own commit

How does the migration to Standalone components work?

Standalone components no longer need NgModules. They declare their dependencies themselves in their own imports. This makes structures flatter and dependencies more visible. The steps and options are described in the Angular documentation on Standalone migration.

The migration runs via a schematic in several passes. You run it successively, check build and tests after each run, and only then commit. This keeps each step small and reversible.

One side effect concerns CommonModule: it largely falls away once the control-flow migration has run, because @if, @for, and @switch are template syntax that do not need to be imported.

Old modules and new Standalone components may temporarily coexist. That is even the norm in large applications. What matters is a clear goal so that the transition does not become a permanent state.

How do you make the switch from the webpack build to the new Application Builder?

The webpack-based build system and the Browser Builder are outdated. The new build system is the Application Builder. Plan the switch as a separate step in your migration.

Start the automatic migration with this command:

ng update @angular/cli --name use-application-builder

Then check whether build, development server, and deployment continue to work as before. Pay special attention to custom webpack configurations and builder extensions, which you should review manually after the migration.

The build migration and the Standalone migration are independent of each other. Do not do them on the same day, so that if something goes wrong you know which change caused it.

How do you test a partially migrated application?

Migrated and not-yet-migrated parts run side by side for a while. Therefore the rule is: after each step, run build, unit tests, and a quick pass through the most important browser flows, such as login, forms, and main pages. If end-to-end tests for these core flows are missing, you should add them first.

For unit tests, the Standalone schematic has limits. It detects direct calls to Angular APIs, so a custom wrapper around TestBed.configureTestingModule is invisible to it. In addition, the imports it adds to components in unit tests are not necessarily fully correct, because specs are not compiled with AOT.

So pay close attention to red tests instead of blindly adding imports. It helps to identify custom test helpers beforehand and adapt them manually after the migration.

If a step goes wrong, the rollback helps: the commit per step allows you to revert exactly that state without losing earlier progress. This keeps the application releasable at all times.

What mistakes happen most often during migration?

The most common mistake is changing too much at once: version jump, Standalone, build system, and control flow in one commit. If an error appears then, it is almost impossible to pinpoint the cause.

The second mistake is blind trust in automation. Schematics handle routine work, but they do not know your custom solutions. Read the diff and start the application before you commit.

Third, custom test helpers and build adjustments that the schematic does not detect are overlooked. And fourth, a special case is confused with standard cases: anyone coming from AngularJS does not migrate with ng update, but usually step by step via ngUpgrade, where both frameworks run in parallel for a time. That is significantly more involved than a version jump within Angular.

How long an Angular project takes to migrate depends mainly on its size, test coverage, number of third-party libraries, and custom solutions. A reliable time estimate is only possible after looking at the code.

Have an Angular project migrated: support from Fidel Seehawer

If you would rather not migrate your Angular project alone, I can support you. Frontend architecture and UI development with Angular are among my focus areas, as are web and mobile development. You can find references in the portfolio with selected client projects.

I see myself as a digital craftsperson who combines engineering and design, and I pay attention to detail and accessibility. I also use AI tools and automation to develop faster and more efficiently. More on that is on the page about my working approach.

You can make first contact via my contact page initially through the chat on the website.

Frequently asked questions

Can I migrate a project from AngularJS to Angular in Angular?

Yes, usually step by step via ngUpgrade. AngularJS and Angular then run in the same application for a time, and you replace parts one after another. This is a separate project and not a normal version jump.

Can I continue to deploy the application during the migration?

Yes, if you proceed step by step and test and commit each step separately. That keeps the project runnable at all times. With a big-bang overhaul, by contrast, deployment is often blocked in between.

Do I have to introduce the new build system immediately?

Not necessarily. Applications can temporarily remain on the Browser Builder. However, the old webpack-based system is considered outdated, so you should plan the switch.

Looking for help with a web project? Discuss a project with Fidel Seehawer.