Migrate AngularJS (1.5) app to Angular 5

I have a question about migrating an AngularJS app to Angular (5 in this case).

I've been reading the official guide but I have some doubts. What I understand in this guide is that you need to migrate from AngularJS app adding libraries of Angular.

However, I'm not sure if is possible to make a new Angular 5 app from scratch and adding some stuff to make it hybrid. It seems that is possible with this guide.

What I need is to migrate an AngularJS app that uses modules (another AngularJS as dependencies) to Angular 5. So the first approach was migrating the main app to Angular 5 and adding the dependencies modules as AngularJS modules (doing some stuff to allow to use they). But I'm not sure if this approach is correct

What do you think is the best approach?

Upvotes: 2

Views: 308

Answers (1)

Rotem jackoby
Rotem jackoby

Reputation: 22128

I'm not aware of the project's size and if its in production use at the moment, but lets assume it is.

I would recommend on writing from scratch, in a step by step approach. Start first of all by making sure that angular 1.X code is written in such a way that it will be easy to use it in an angular 5 project:

  1. Make sure each component contains all of its markup and styling. and is written in at least a "class like" pattern (if you use ES5), so it will be easy to switch to typescript.
  2. Structure of your app - core/shared/feature modules like angular suggest. and follow there style guide.
  3. 3rd party libraries - make sure that all of them has a stable support for angular 5. For example when i migrated one of my projects to angular 5 i found that material's navbar component wasn't stable yet for angular 2+, and it took some time to adjust it.

You would have to maintain two repos (1.X and 5) for quiet some time, but for a personal experience it can be also a great opportunity, to re-design you system to a better one, because now you have a wider view of all the business logic that was changed over time, so you can choose new approaches.

Upvotes: 1

Related Questions