Migration from Angular 2 Betas to RC

On May 2nd Angular 2 moved from the beta stage to the release candidate stage and is currently on RC 1. The move from beta to RC was a bit more involved than the moves between beta. This post is going to cover the changes I went through to get my SPA sample application migrated to RC 1.

Update package.json

With this release Angular 2 was split from a single dependency in to multiple. The other big change is a rename of from angular2  to @angular. The following is my updated dependencies section.

After the above change make sure to run  npm install in the root of the project from a command prompt. Not sure if it was just me, but the dependency auto restore in Visual Studio wouldn’t work for the @angular dependencies.

Update gulpfile.js

Due to the changes in the dependency structure my gulpfile had to be updated to copy the new files to the proper locations. I took the opportunity to move all of my dependency to a lib folder.

If you were using the previous version of my gulp take make sure to remove the old dependencies from the wwwroot/Angular/ folder.

Update Entry Point View

Again because of the dependency changes the entry point view for the Angular 2 application needed changes which is Angular2.cshtml in my project. A systemjs.config.js was added to handle the bulk of the configuration. The following is the full source for my entry point view.

Add system.config.js

This new file is where the configuration of systemjs happens. I found this setup in Dan Wahlin’s Angular2-JumpStart project which can be found here. The only real changes I made from Dan’s file was to adjust the map section to match my folder layout.

Update Component Imports

With the change in package names all imports that were using  angular2 need to be changed to  @angular. The following is an example of this from my app.component.ts file.

NgFor Change

There was also a slight syntax change around  ngFor that changes the name declaration of the current item in the iteration of a loop. The following shows the before and after.

Complete

With the above changes my application was run able again. The hardest part of the upgrade for me was getting systemjs configured properly. Hope your upgrade goes smooth and if not leave a comment with what issues you had.

4 thoughts on “Migration from Angular 2 Betas to RC”

  1. hiii, i am working in old angular2 rc1. my task is to convert it to new latest rc6. i am doing it manual. its so complicated to convert each component syntax to rc6 syntax.. is there any migration technique that convert all component together. if possible plzz suggest

    1. I do plan to revisit Angular 2 in the future, but it will be from the point of a new project not an upgrade. Best of luck in your migration!

      Feel free to come back and leave comments if you find your answer.

Leave a Reply

Your email address will not be published. Required fields are marked *