SlideShare a Scribd company logo
1 of 51
JHipster 4.0
The Angular Migration
by Flavien Cathala and William Marques
Who are we ?
William Marques Flavien Cathala
@wylmarq
wmarques@ippon.fr
JHipster Member
Ippon Consultant
@flaviencathala
fcathala@ippon.fr
JHipster Member
Epitech Student
Summary
1. Introduction
2. Prepare your migration
3. Angular 2 ecosystem
4. Step-by-step migration
5. After the migration
Migration on JHipster
JHipster Team
VictorJulien Deepu William Flavien Sendil
Kurman
Migration on JHipster
Contributors
Chris Thielen
UI Router founder
Sean Larkin
Webpack member
Migration on JHipster
Chronology
Start of
migration
June
Migration to
Webpack
November
Entities
Tests
December
End ?
January
Dependencies
September
Angular 2
- New syntax
- New concepts
Officially released in September 2016 with:
AngularJS vs Angular 2
Javascript Typescript
MVC Component Oriented
Promise Observable
AngularJS Angular 2
Why migrating ?
- Better performances
- More adapted to mobile terminals
- Better productivity
- AngularJS will be deprecated
PREPARE
YOURSELF
Follow the John Papa style
Major rules :
Folder-By-Feature
Scope Isolation (controllerAs “vm”)
IIFE (avoid minification conflicts)
https://github.com/johnpapa/angular-styleguide/tree/master/a1
(that’s him)
Be modular !
Create module files and declare your controllers and factories there
Code is cleaner
Easy module loader setup
Source: https://github.com/tuchk4/requirejs-angular-loader
Do Components
Only available in >= 1.5.x
Easy switch to Angular 2 Component
Promote best practices (scope isolation)
One-way binding possible
angular.module('heroApp').component('heroDetail', {
templateUrl: 'heroDetail.html',
controller: HeroDetailController,
bindings: {
hero: '='
}
});
BONUS 1 : Do TypeScript
Spoiler : You will write TypeScript with Angular 2 (widely recommended)
Add classes, types, imports in your code
Very easy migration to Angular 2
https://codepen.io/martinmcwhorter/post/angularjs-1-x-with-typescript-or-es6-best-practices
BONUS 2 : Yarn
New package manager (another one)
Much faster
Easy to use (same command as NPM)
Avoid “works on my machine” issue
Offline Installation
Angular 2 ecosystem
Module loader
Why ?
- Code complexity
- Performances
- Avoid injection of huge number of files in index
Module loader
Complexity ** **
Maintainability * ***
Performances * ***
SystemJS Webpack
Which one ?
Module loader
Why Webpack ?
Migration to Webpack
+
Webpack
webpack.common
webpack.dev
webpack.prod
polyfills
vendor
webpack.dev.js
const webpackMerge = require('webpack-merge');
const commonConfig = require('./webpack.common.js');
const ENV = 'prod';
module.exports = webpackMerge(commonConfig({env: ENV}), {
output: {
filename: '[hash].[name].bundle.js',
chunkFilename: '[hash].[id].chunk.js'
},
plugins: [
new ExtractTextPlugin('[hash].styles.css')
]
});
Webpack
webpack.prod.js
const webpackMerge = require('webpack-merge');
const commonConfig = require('./webpack.common.js');
const ENV = 'dev';
module.exports = webpackMerge(commonConfig({env: ENV}),
{
module: {
rules: [{
test: /.ts$/,
loaders: [
'tslint'
]
}]
},
plugins: [
new BrowserSyncPlugin({
host: 'localhost',
port: 9000,
proxy: 'http://localhost:8080'
}),
new ExtractTextPlugin('styles.css'),
new webpack.NoErrorsPlugin()
]
});
polyfills.ts
import 'bootstrap/dist/css/bootstrap.min.css';
import 'font-awesome/css/font-awesome.min.css';
Webpack
vendor.ts
import 'reflect-metadata/Reflect';
import 'zone.js/dist/zone';
module.exports = function (options) {
const DATAS = {
VERSION:
JSON.stringify(require("../package.json").version),
DEBUG_INFO_ENABLED: options.env === 'dev'
};
return {
entry: {
'polyfills': './src/main/webapp/app/polyfills',
'vendor': './src/main/webapp/app/vendor',
'main': './src/main/webapp/app/app.main'
},
resolve: {
extensions: ['.ts', '.js'],
modules: ['node_modules']
},
output: {
path: './target/www',
filename: '[name].bundle.js',
chunkFilename: '[id].chunk.js'
},
webpack.common.js
Webpack
How to run Webpack ?
webpack --watch --config webpack/webpack.dev.js
webpack -p --config webpack/webpack.prod.js
Using NPM scripts
package.json
"scripts": {
"webpack:dev": "webpack --watch --config
webpack/webpack.dev.js",
"webpack:prod": "webpack -p --config webpack/webpack.prod.js"
}
npm run webpack:dev
npm run webpack:prod
Command lines
Package managers
THE MIGRATION
Migration Plan : Bottom Up
1. Setup migration (install Angular 2 packages, the hybrid app)
2. Migrate small controllers, services, templates (leafs) and then their
parents
3. Migrate routes
4. Check 3rd party dependencies (Angular UI, Angular Translate)
5. Remove AngularJS Code / Dependencies
upgradeAdapter
Incremental Update (hybrid app)
Upgrade your Angular 1 Services, Controllers…
Downgrade your Angular 2 Services, Components…
Bad performance (temporary solution)
Why ?
Setup
Remove ng-app and strict-di attribute in your template
Create an app.main.ts :
upgradeAdapter.bootstrap(document.body, ['myApp.app'], {strictDi: true});
Setup
import * as angular from 'angular';
import { UpgradeAdapter } from '@angular/upgrade';
import { forwardRef } from '@angular/core';
import { Ng2BasicAppModule } from './app.ng2module';
export var upgradeAdapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2BasicAppModule));
Create an upgrade_adapter.ts file
Usage
Downgrade an Angular 2 Component to use it in your Angular 1 App,
add in your module file :
For a service :
.directive(‘home’, <angular.IDirectiveFactory> upgradeAdapter.downgradeNg2Component(HomeComponent))
.factory(‘example’, adapter.downgradeNg2Provider(Example));
Controller Migration
- Remove the IIFE
- Remove the $inject
- Use the @Component annotation
- Replace controller function by class
Controller Migration
import { Component, OnInit, Inject } from '@angular/core';
import { StateService } from "ui-router-ng2";
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { Account, LoginModalService, Principal } from "../shared";
@Component({
selector: 'home',
templateUrl: './home.html'
})
export class HomeComponent implements OnInit {
account: Account;
modalRef: NgbModalRef;
constructor(
private principal: Principal,
private $state: StateService,
private loginModalService: LoginModalService
) {}
ngOnInit() {
this.principal.identity().then((account) => {
this.account = account;
});
}
isAuthenticated() {
return this.principal.isAuthenticated();
}
login() {
this.modalRef = this.loginModalService.open();
}
}
(function() {
'use strict';
angular
.module('ng2FinalApp')
.controller('HomeController', HomeController);
HomeController.$inject = ['$scope', 'Principal', 'LoginService', '$state'];
function HomeController ($scope, Principal, LoginService, $state) {
var vm = this;
vm.account = null;
vm.isAuthenticated = null;
vm.login = LoginService.open;
vm.register = register;
$scope.$on('authenticationSuccess', function() {
getAccount();
});
getAccount();
function getAccount() {
Principal.identity().then(function(account) {
vm.account = account;
vm.isAuthenticated = Principal.isAuthenticated;
});
}
function register () {
$state.go('register');
}
}
})();
Same refactoring as controllers
Add your service in the providers array of your Angular 2 Module in order to
inject it in your Angular 2 Components
Downgrade it using the upgradeAdapter in your Angular 1 Module :
Service migration
.factory('example', adapter.downgradeNg2Provider(Example));
Service Migration
1 2
(function() {
'use strict';
angular
.module('ng2FinalApp')
.factory('LogsService', LogsService);
LogsService.$inject = ['$resource'];
function LogsService ($resource) {
var service = $resource('management/jhipster/logs', {}, {
'findAll': { method: 'GET', isArray: true},
'changeLevel': { method: 'PUT'}
});
return service;
}
})();
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { Log } from './log.model';
@Injectable()
export class LogsService {
constructor(private http: Http) { }
changeLevel(log: Log): Observable<Response> {
return this.http.put('management/jhipster/logs', log);
}
findAll(): Observable<Log[]> {
return this.http.get('management/jhipster/logs').map((res:
Response) => res.json());
}
}
Angular 1 Dependency in Angular 2 ?
Upgrade the Angular 1 provider in your module file, using the upgradeAdapter:
Use the @Inject annotation in your Angular 2 controller/service constructor :
Same for Angular 1 lib dependencies ($state, $rootScope… )
@Inject('heroes') heroes: HeroesService
adapter.upgradeNg1Provider('heroes');
Routes Migration
Angular 2 Router UI-Router NG2
Default solution for Angular Team
Inspired by AngularJS UI Router
Component Oriented
Easy migration from UI Router NG 1
Visualizer feature
Breaking changes from UI Router NG1 Not the official Solution
Final Decision : UI-Router NG2, because of their contribution to JHipster
NG2 Router or UI-Router ?
Route Migration: Setup
Install ui-router-ng1-to-ng2 and ui-router-ng2 NPM packages
Add uirouter.upgrade module dependency in your Angular 1 Module
Add Ng1ToNg2Module in your Angular 2 Module
let ng1module = angular.module("myApp", [uiRouter, 'ui.router.upgrade']);
@NgModule({
imports: [ BrowserModule, Ng1ToNg2Module ]
}) class SampleAppModule {}
Route Migration : UpgradeAdapter
In your upgrade_adapter.ts file, add these lines :
import { uiRouterNgUpgrade } from "ui-router-ng1-to-ng2";
uiRouterNgUpgrade.setUpgradeAdapter(upgradeAdapter);
Route migration : refactoring
import { RegisterComponent } from './register.component';
import { JhiLanguageService } from '../../shared';
export const registerState = {
name: 'register',
parent: 'account',
url: '/register',
data: {
authorities: [],
pageTitle: 'register.title'
},
views: {
'content@': { component: RegisterComponent }
},
resolve: [{
token: 'translate',
deps: [JhiLanguageService],
resolveFn: (languageService) => languageService.setLocations(['register'])
}]
};
(function() {
'use strict';
angular
.module('ng2FinalApp')
.config(stateConfig);
stateConfig.$inject = ['$stateProvider'];
function stateConfig($stateProvider) {
$stateProvider.state('register', {
parent: 'account',
url: '/register',
data: {
authorities: [],
pageTitle: 'register.title'
},
views: {
'content@': {
templateUrl: 'app/account/register/register.html',
controller: 'RegisterController',
controllerAs: 'vm'
}
},
resolve: {
translatePartialLoader: ['$translate', '$translatePartialLoader',
function ($translate, $translatePartialLoader) {
$translatePartialLoader.addPart('register');
return $translate.refresh();
}]
}
});
}
})();
Route migration : Route Declaration
let ACCOUNT_STATES = [
accountState,
activateState,
passwordState,
finishResetState,
requestResetState,
registerState,
sessionsState,
settingsState
];
@NgModule({
imports: [
Ng2BasicSharedModule,
UIRouterModule.forChild({ states: ACCOUNT_STATES })
],
declarations: [
ActivateComponent,
RegisterComponent,
PasswordComponent,
PasswordResetInitComponent,
PasswordResetFinishComponent,
SessionsComponent,
SettingsComponent
],
providers: [
SessionsService,
Register,
Activate,
Password,
PasswordResetInit,
PasswordResetFinish
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class Ng2BasicAccountModule {}
Add your routes in a variable and then import them using UIRouterModule.forChild :
Templates migration
ng-class [ngClass]
ng-click (click)
ng-if *ngIf
ng-model [(ngModel)]
ng-repeat *ngFor
AngularJS Angular 2
Templates migration
<div class="modal-header">
<button class="close" type="button"
(click)="activeModal.dismiss('closed')">x
</button>
<h4 class="modal-title">Sign in</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-4 col-md-offset-4">
<h1 jhi-translate="login.title">Sign in</h1>
</div>
<div class="col-md-8 col-md-offset-2">
<div class="alert-danger" *ngIf="authenticationError">
<strong>Failed to sign in!</strong>
</div>
</div>
<div class="col-md-8 col-md-offset-2">
<form class="form" role="form" (ngSubmit)="login()">
<div class="form-group">
<label for="username">Login</label>
<input type="text" class="form-control" name="username"
id="username" [(ngModel)]="username">
</div>
<div class="modal-header">
<button type="button" class="close"
ng-click="vm.cancel()">&times;</button>
<h4 class="modal-title">Sign in</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-4 col-md-offset-4">
<h1 data-translate="login.title">Sign in</h1>
</div>
<div class="col-md-8 col-md-offset-2">
<div class="alert-danger" ng-show="vm.authenticationError">
<strong>Failed to sign in!</strong>
</div>
</div>
<div class="col-md-8 col-md-offset-2">
<form class="form" role="form" ng-submit="vm.login($event)">
<div class="form-group">
<label for="username">Login</label>
<input type="text" class="form-control"
id="username" ng-model="vm.username">
</div>
Dependencies migration
- angular-ui
ng-bootstrap- angular-translate
ng2-translate
Some external dependencies needed to be replaced/updated:
- ...
Remove AngularJS
- Remove upgradeAdapter
- Remove all AngularJS files
Once everything has been migrated:
CONCLUSION
Migration Feedback
A lot of new technologies and architectures
Difficult process
Some libs are poorly documented and in alpha
Only a few projects already migrated
Many different choices (Router, Module Loader)
Don’t do it yourself : Use JHipster ;-)
About Angular 2...
Modern approach (Component oriented)
TypeScript Features (types, ES6)
Cleaner code
Less tools (only NPM)
What’s next ?
Router discussions
Hot Module Loader
Ahead Of Time compilation
Finish migration for all configurations
Demo
Questions ?

More Related Content

What's hot

Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_jsMicroPyramid .
 
A Closer Look At React Native
A Closer Look At React NativeA Closer Look At React Native
A Closer Look At React NativeIan Wang
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2Knoldus Inc.
 
Java Intro: Unit1. Hello World
Java Intro: Unit1. Hello WorldJava Intro: Unit1. Hello World
Java Intro: Unit1. Hello WorldYakov Fain
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScriptYakov Fain
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in ReactTalentica Software
 
Web sockets in Angular
Web sockets in AngularWeb sockets in Angular
Web sockets in AngularYakov Fain
 
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav DukhinFwdays
 
Migrating an application from Angular 1 to Angular 2
Migrating an application from Angular 1 to Angular 2 Migrating an application from Angular 1 to Angular 2
Migrating an application from Angular 1 to Angular 2 Ross Dederer
 
Spring Boot and Microservices
Spring Boot and MicroservicesSpring Boot and Microservices
Spring Boot and Microservicesseges
 
ReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparisonReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparison500Tech
 
GWTcon 2015 - Beyond GWT 3.0 Panic
GWTcon 2015 - Beyond GWT 3.0 PanicGWTcon 2015 - Beyond GWT 3.0 Panic
GWTcon 2015 - Beyond GWT 3.0 PanicCristiano Costantini
 
sbt 0.10 for beginners?
sbt 0.10 for beginners?sbt 0.10 for beginners?
sbt 0.10 for beginners?k4200
 
Lifthub (rpscala #31)
Lifthub (rpscala #31)Lifthub (rpscala #31)
Lifthub (rpscala #31)k4200
 
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2Building Universal Applications with Angular 2
Building Universal Applications with Angular 2Minko Gechev
 
Angular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersAngular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersOswald Campesato
 
Angular 2: What's New?
Angular 2: What's New?Angular 2: What's New?
Angular 2: What's New?jbandi
 
Angular2 with type script
Angular2 with type scriptAngular2 with type script
Angular2 with type scriptRavi Mone
 
Type script for_java_dev_jul_2020
Type script for_java_dev_jul_2020Type script for_java_dev_jul_2020
Type script for_java_dev_jul_2020Yakov Fain
 

What's hot (20)

Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_js
 
A Closer Look At React Native
A Closer Look At React NativeA Closer Look At React Native
A Closer Look At React Native
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
 
Java Intro: Unit1. Hello World
Java Intro: Unit1. Hello WorldJava Intro: Unit1. Hello World
Java Intro: Unit1. Hello World
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
 
Web sockets in Angular
Web sockets in AngularWeb sockets in Angular
Web sockets in Angular
 
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
 
Migrating an application from Angular 1 to Angular 2
Migrating an application from Angular 1 to Angular 2 Migrating an application from Angular 1 to Angular 2
Migrating an application from Angular 1 to Angular 2
 
Spring Boot and Microservices
Spring Boot and MicroservicesSpring Boot and Microservices
Spring Boot and Microservices
 
ReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparisonReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparison
 
GWTcon 2015 - Beyond GWT 3.0 Panic
GWTcon 2015 - Beyond GWT 3.0 PanicGWTcon 2015 - Beyond GWT 3.0 Panic
GWTcon 2015 - Beyond GWT 3.0 Panic
 
sbt 0.10 for beginners?
sbt 0.10 for beginners?sbt 0.10 for beginners?
sbt 0.10 for beginners?
 
Lifthub (rpscala #31)
Lifthub (rpscala #31)Lifthub (rpscala #31)
Lifthub (rpscala #31)
 
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
 
Angular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersAngular1x and Angular 2 for Beginners
Angular1x and Angular 2 for Beginners
 
React on es6+
React on es6+React on es6+
React on es6+
 
Angular 2: What's New?
Angular 2: What's New?Angular 2: What's New?
Angular 2: What's New?
 
Angular2 with type script
Angular2 with type scriptAngular2 with type script
Angular2 with type script
 
Type script for_java_dev_jul_2020
Type script for_java_dev_jul_2020Type script for_java_dev_jul_2020
Type script for_java_dev_jul_2020
 

Viewers also liked

第三回ありえる社内勉強会 「いわががのLombok」
第三回ありえる社内勉強会 「いわががのLombok」第三回ありえる社内勉強会 「いわががのLombok」
第三回ありえる社内勉強会 「いわががのLombok」yoshiaki iwanaga
 
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016Matt Raible
 
1.3 y 1.4 subject and predicate
1.3 y 1.4 subject and predicate1.3 y 1.4 subject and predicate
1.3 y 1.4 subject and predicatepaolyta28
 
AngularJS Version 1.3
AngularJS  Version 1.3AngularJS  Version 1.3
AngularJS Version 1.3Nir Noy
 
Angular 1.x reloaded: improve your app now! and get ready for 2.0
Angular 1.x reloaded:  improve your app now! and get ready for 2.0Angular 1.x reloaded:  improve your app now! and get ready for 2.0
Angular 1.x reloaded: improve your app now! and get ready for 2.0Carlo Bonamico
 
Componentes en angularjs 1.5
Componentes en angularjs 1.5Componentes en angularjs 1.5
Componentes en angularjs 1.5Hugo Biarge
 
さわってみようReact.js、AngularJS(1系、2系)
さわってみようReact.js、AngularJS(1系、2系)さわってみようReact.js、AngularJS(1系、2系)
さわってみようReact.js、AngularJS(1系、2系)Kazuhiro Yoshimoto
 
Code migration from Angular 1.x to Angular 2.0
Code migration from Angular 1.x to Angular 2.0Code migration from Angular 1.x to Angular 2.0
Code migration from Angular 1.x to Angular 2.0Ran Wahle
 
Comment réussir son projet en Angular 1.5 ?
Comment réussir son projet en Angular 1.5 ?Comment réussir son projet en Angular 1.5 ?
Comment réussir son projet en Angular 1.5 ?Maxime Bernard
 
Microservices for the Masses with Spring Boot, JHipster, and JWT - Rich Web 2016
Microservices for the Masses with Spring Boot, JHipster, and JWT - Rich Web 2016Microservices for the Masses with Spring Boot, JHipster, and JWT - Rich Web 2016
Microservices for the Masses with Spring Boot, JHipster, and JWT - Rich Web 2016Matt Raible
 
Introduction to angular 2
Introduction to angular 2Introduction to angular 2
Introduction to angular 2Dhyego Fernando
 
What's New in JHipsterLand - DevNexus 2017
What's New in JHipsterLand - DevNexus 2017What's New in JHipsterLand - DevNexus 2017
What's New in JHipsterLand - DevNexus 2017Matt Raible
 
Angular 2 - The Next Framework
Angular 2 - The Next FrameworkAngular 2 - The Next Framework
Angular 2 - The Next FrameworkCommit University
 
Angular 2 vs Angular 1
Angular 2 vs Angular 1Angular 2 vs Angular 1
Angular 2 vs Angular 1GDG Odessa
 
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Angular Summit 2015
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Angular Summit 2015Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Angular Summit 2015
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Angular Summit 2015Matt Raible
 
AngularJS 2, version 1 and ReactJS
AngularJS 2, version 1 and ReactJSAngularJS 2, version 1 and ReactJS
AngularJS 2, version 1 and ReactJSKenneth Ceyer
 
Quick introduction to Angular 4 for AngularJS 1.5 developers
Quick introduction to Angular 4 for AngularJS 1.5 developersQuick introduction to Angular 4 for AngularJS 1.5 developers
Quick introduction to Angular 4 for AngularJS 1.5 developersPaweł Żurowski
 

Viewers also liked (20)

第三回ありえる社内勉強会 「いわががのLombok」
第三回ありえる社内勉強会 「いわががのLombok」第三回ありえる社内勉強会 「いわががのLombok」
第三回ありえる社内勉強会 「いわががのLombok」
 
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
 
Hipster lab
Hipster labHipster lab
Hipster lab
 
1.3 y 1.4 subject and predicate
1.3 y 1.4 subject and predicate1.3 y 1.4 subject and predicate
1.3 y 1.4 subject and predicate
 
AngularJS Version 1.3
AngularJS  Version 1.3AngularJS  Version 1.3
AngularJS Version 1.3
 
Angular 1.x reloaded: improve your app now! and get ready for 2.0
Angular 1.x reloaded:  improve your app now! and get ready for 2.0Angular 1.x reloaded:  improve your app now! and get ready for 2.0
Angular 1.x reloaded: improve your app now! and get ready for 2.0
 
Componentes en angularjs 1.5
Componentes en angularjs 1.5Componentes en angularjs 1.5
Componentes en angularjs 1.5
 
さわってみようReact.js、AngularJS(1系、2系)
さわってみようReact.js、AngularJS(1系、2系)さわってみようReact.js、AngularJS(1系、2系)
さわってみようReact.js、AngularJS(1系、2系)
 
Code migration from Angular 1.x to Angular 2.0
Code migration from Angular 1.x to Angular 2.0Code migration from Angular 1.x to Angular 2.0
Code migration from Angular 1.x to Angular 2.0
 
Comment réussir son projet en Angular 1.5 ?
Comment réussir son projet en Angular 1.5 ?Comment réussir son projet en Angular 1.5 ?
Comment réussir son projet en Angular 1.5 ?
 
Microservices for the Masses with Spring Boot, JHipster, and JWT - Rich Web 2016
Microservices for the Masses with Spring Boot, JHipster, and JWT - Rich Web 2016Microservices for the Masses with Spring Boot, JHipster, and JWT - Rich Web 2016
Microservices for the Masses with Spring Boot, JHipster, and JWT - Rich Web 2016
 
Typescript ppt
Typescript pptTypescript ppt
Typescript ppt
 
Introduction to angular 2
Introduction to angular 2Introduction to angular 2
Introduction to angular 2
 
What's New in JHipsterLand - DevNexus 2017
What's New in JHipsterLand - DevNexus 2017What's New in JHipsterLand - DevNexus 2017
What's New in JHipsterLand - DevNexus 2017
 
Angular 2 - The Next Framework
Angular 2 - The Next FrameworkAngular 2 - The Next Framework
Angular 2 - The Next Framework
 
Angular 2 vs Angular 1
Angular 2 vs Angular 1Angular 2 vs Angular 1
Angular 2 vs Angular 1
 
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Angular Summit 2015
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Angular Summit 2015Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Angular Summit 2015
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Angular Summit 2015
 
AngularJS 2, version 1 and ReactJS
AngularJS 2, version 1 and ReactJSAngularJS 2, version 1 and ReactJS
AngularJS 2, version 1 and ReactJS
 
Quick introduction to Angular 4 for AngularJS 1.5 developers
Quick introduction to Angular 4 for AngularJS 1.5 developersQuick introduction to Angular 4 for AngularJS 1.5 developers
Quick introduction to Angular 4 for AngularJS 1.5 developers
 
Angular 2 - Better or worse
Angular 2 - Better or worseAngular 2 - Better or worse
Angular 2 - Better or worse
 

Similar to Angular 2 Migration - JHipster Meetup 6

Angular%201%20to%20angular%202
Angular%201%20to%20angular%202Angular%201%20to%20angular%202
Angular%201%20to%20angular%202Ran Wahle
 
Commit University - Exploring Angular 2
Commit University - Exploring Angular 2Commit University - Exploring Angular 2
Commit University - Exploring Angular 2Commit University
 
Spring Performance Gains
Spring Performance GainsSpring Performance Gains
Spring Performance GainsVMware Tanzu
 
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0Frost
 
Sharper Better Faster Dagger ‡ - Droidcon SF
Sharper Better Faster Dagger ‡ - Droidcon SFSharper Better Faster Dagger ‡ - Droidcon SF
Sharper Better Faster Dagger ‡ - Droidcon SFPierre-Yves Ricau
 
Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Matt Raible
 
Peggy angular 2 in meteor
Peggy   angular 2 in meteorPeggy   angular 2 in meteor
Peggy angular 2 in meteorLearningTech
 
Angular 2 - Core Concepts
Angular 2 - Core ConceptsAngular 2 - Core Concepts
Angular 2 - Core ConceptsFabio Biondi
 
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)Ontico
 
Zukunftssichere Anwendungen mit AngularJS 1.x entwickeln (GDG DevFest Karlsru...
Zukunftssichere Anwendungen mit AngularJS 1.x entwickeln (GDG DevFest Karlsru...Zukunftssichere Anwendungen mit AngularJS 1.x entwickeln (GDG DevFest Karlsru...
Zukunftssichere Anwendungen mit AngularJS 1.x entwickeln (GDG DevFest Karlsru...Christian Janz
 
Introduction to Angular2
Introduction to Angular2Introduction to Angular2
Introduction to Angular2Ivan Matiishyn
 
Angular 2 for Java Developers
Angular 2 for Java DevelopersAngular 2 for Java Developers
Angular 2 for Java DevelopersYakov Fain
 
Meetup SkillValue - Angular 6 : Bien démarrer son application
Meetup SkillValue - Angular 6 : Bien démarrer son applicationMeetup SkillValue - Angular 6 : Bien démarrer son application
Meetup SkillValue - Angular 6 : Bien démarrer son applicationThibault Even
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteorSapna Upreti
 
Angular 2: core concepts
Angular 2: core conceptsAngular 2: core concepts
Angular 2: core conceptsCodemotion
 

Similar to Angular 2 Migration - JHipster Meetup 6 (20)

Angular2 + rxjs
Angular2 + rxjsAngular2 + rxjs
Angular2 + rxjs
 
Angular%201%20to%20angular%202
Angular%201%20to%20angular%202Angular%201%20to%20angular%202
Angular%201%20to%20angular%202
 
Commit University - Exploring Angular 2
Commit University - Exploring Angular 2Commit University - Exploring Angular 2
Commit University - Exploring Angular 2
 
Spring Performance Gains
Spring Performance GainsSpring Performance Gains
Spring Performance Gains
 
Angular 2 - a New Hope
Angular 2 - a New HopeAngular 2 - a New Hope
Angular 2 - a New Hope
 
Angular 2.0
Angular  2.0Angular  2.0
Angular 2.0
 
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
 
Angular 2.0 - What to expect
Angular 2.0 - What to expectAngular 2.0 - What to expect
Angular 2.0 - What to expect
 
Sharper Better Faster Dagger ‡ - Droidcon SF
Sharper Better Faster Dagger ‡ - Droidcon SFSharper Better Faster Dagger ‡ - Droidcon SF
Sharper Better Faster Dagger ‡ - Droidcon SF
 
Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017
 
Peggy angular 2 in meteor
Peggy   angular 2 in meteorPeggy   angular 2 in meteor
Peggy angular 2 in meteor
 
Angular 2 - Core Concepts
Angular 2 - Core ConceptsAngular 2 - Core Concepts
Angular 2 - Core Concepts
 
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
 
Zukunftssichere Anwendungen mit AngularJS 1.x entwickeln (GDG DevFest Karlsru...
Zukunftssichere Anwendungen mit AngularJS 1.x entwickeln (GDG DevFest Karlsru...Zukunftssichere Anwendungen mit AngularJS 1.x entwickeln (GDG DevFest Karlsru...
Zukunftssichere Anwendungen mit AngularJS 1.x entwickeln (GDG DevFest Karlsru...
 
Introduction to Angular2
Introduction to Angular2Introduction to Angular2
Introduction to Angular2
 
Angular 2 for Java Developers
Angular 2 for Java DevelopersAngular 2 for Java Developers
Angular 2 for Java Developers
 
Meetup SkillValue - Angular 6 : Bien démarrer son application
Meetup SkillValue - Angular 6 : Bien démarrer son applicationMeetup SkillValue - Angular 6 : Bien démarrer son application
Meetup SkillValue - Angular 6 : Bien démarrer son application
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
Angular 2: core concepts
Angular 2: core conceptsAngular 2: core concepts
Angular 2: core concepts
 
Meteor
MeteorMeteor
Meteor
 

Recently uploaded

PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationLinaWolf1
 
NSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationNSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationMarko4394
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一Fs
 
Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Excelmac1
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITMgdsc13
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一z xss
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
Magic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptxMagic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptxMartaLoveguard
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Sonam Pathan
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一Fs
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxeditsforyah
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)Christopher H Felton
 
Elevate Your Business with Our IT Expertise in New Orleans
Elevate Your Business with Our IT Expertise in New OrleansElevate Your Business with Our IT Expertise in New Orleans
Elevate Your Business with Our IT Expertise in New Orleanscorenetworkseo
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一Fs
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Sonam Pathan
 

Recently uploaded (20)

young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 Documentation
 
NSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationNSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentation
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
 
Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
Magic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptxMagic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptx
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptx
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
 
Elevate Your Business with Our IT Expertise in New Orleans
Elevate Your Business with Our IT Expertise in New OrleansElevate Your Business with Our IT Expertise in New Orleans
Elevate Your Business with Our IT Expertise in New Orleans
 
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170
 

Angular 2 Migration - JHipster Meetup 6

  • 1. JHipster 4.0 The Angular Migration by Flavien Cathala and William Marques
  • 2. Who are we ? William Marques Flavien Cathala @wylmarq wmarques@ippon.fr JHipster Member Ippon Consultant @flaviencathala fcathala@ippon.fr JHipster Member Epitech Student
  • 3. Summary 1. Introduction 2. Prepare your migration 3. Angular 2 ecosystem 4. Step-by-step migration 5. After the migration
  • 4. Migration on JHipster JHipster Team VictorJulien Deepu William Flavien Sendil Kurman
  • 5. Migration on JHipster Contributors Chris Thielen UI Router founder Sean Larkin Webpack member
  • 6. Migration on JHipster Chronology Start of migration June Migration to Webpack November Entities Tests December End ? January Dependencies September
  • 7. Angular 2 - New syntax - New concepts Officially released in September 2016 with:
  • 8. AngularJS vs Angular 2 Javascript Typescript MVC Component Oriented Promise Observable AngularJS Angular 2
  • 9. Why migrating ? - Better performances - More adapted to mobile terminals - Better productivity - AngularJS will be deprecated
  • 11. Follow the John Papa style Major rules : Folder-By-Feature Scope Isolation (controllerAs “vm”) IIFE (avoid minification conflicts) https://github.com/johnpapa/angular-styleguide/tree/master/a1 (that’s him)
  • 12. Be modular ! Create module files and declare your controllers and factories there Code is cleaner Easy module loader setup Source: https://github.com/tuchk4/requirejs-angular-loader
  • 13. Do Components Only available in >= 1.5.x Easy switch to Angular 2 Component Promote best practices (scope isolation) One-way binding possible angular.module('heroApp').component('heroDetail', { templateUrl: 'heroDetail.html', controller: HeroDetailController, bindings: { hero: '=' } });
  • 14. BONUS 1 : Do TypeScript Spoiler : You will write TypeScript with Angular 2 (widely recommended) Add classes, types, imports in your code Very easy migration to Angular 2 https://codepen.io/martinmcwhorter/post/angularjs-1-x-with-typescript-or-es6-best-practices
  • 15. BONUS 2 : Yarn New package manager (another one) Much faster Easy to use (same command as NPM) Avoid “works on my machine” issue Offline Installation
  • 17. Module loader Why ? - Code complexity - Performances - Avoid injection of huge number of files in index
  • 18. Module loader Complexity ** ** Maintainability * *** Performances * *** SystemJS Webpack Which one ?
  • 22. webpack.dev.js const webpackMerge = require('webpack-merge'); const commonConfig = require('./webpack.common.js'); const ENV = 'prod'; module.exports = webpackMerge(commonConfig({env: ENV}), { output: { filename: '[hash].[name].bundle.js', chunkFilename: '[hash].[id].chunk.js' }, plugins: [ new ExtractTextPlugin('[hash].styles.css') ] }); Webpack webpack.prod.js const webpackMerge = require('webpack-merge'); const commonConfig = require('./webpack.common.js'); const ENV = 'dev'; module.exports = webpackMerge(commonConfig({env: ENV}), { module: { rules: [{ test: /.ts$/, loaders: [ 'tslint' ] }] }, plugins: [ new BrowserSyncPlugin({ host: 'localhost', port: 9000, proxy: 'http://localhost:8080' }), new ExtractTextPlugin('styles.css'), new webpack.NoErrorsPlugin() ] });
  • 23. polyfills.ts import 'bootstrap/dist/css/bootstrap.min.css'; import 'font-awesome/css/font-awesome.min.css'; Webpack vendor.ts import 'reflect-metadata/Reflect'; import 'zone.js/dist/zone'; module.exports = function (options) { const DATAS = { VERSION: JSON.stringify(require("../package.json").version), DEBUG_INFO_ENABLED: options.env === 'dev' }; return { entry: { 'polyfills': './src/main/webapp/app/polyfills', 'vendor': './src/main/webapp/app/vendor', 'main': './src/main/webapp/app/app.main' }, resolve: { extensions: ['.ts', '.js'], modules: ['node_modules'] }, output: { path: './target/www', filename: '[name].bundle.js', chunkFilename: '[id].chunk.js' }, webpack.common.js
  • 24. Webpack How to run Webpack ? webpack --watch --config webpack/webpack.dev.js webpack -p --config webpack/webpack.prod.js Using NPM scripts package.json "scripts": { "webpack:dev": "webpack --watch --config webpack/webpack.dev.js", "webpack:prod": "webpack -p --config webpack/webpack.prod.js" } npm run webpack:dev npm run webpack:prod Command lines
  • 27. Migration Plan : Bottom Up 1. Setup migration (install Angular 2 packages, the hybrid app) 2. Migrate small controllers, services, templates (leafs) and then their parents 3. Migrate routes 4. Check 3rd party dependencies (Angular UI, Angular Translate) 5. Remove AngularJS Code / Dependencies
  • 28. upgradeAdapter Incremental Update (hybrid app) Upgrade your Angular 1 Services, Controllers… Downgrade your Angular 2 Services, Components… Bad performance (temporary solution) Why ?
  • 29. Setup Remove ng-app and strict-di attribute in your template Create an app.main.ts : upgradeAdapter.bootstrap(document.body, ['myApp.app'], {strictDi: true});
  • 30. Setup import * as angular from 'angular'; import { UpgradeAdapter } from '@angular/upgrade'; import { forwardRef } from '@angular/core'; import { Ng2BasicAppModule } from './app.ng2module'; export var upgradeAdapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2BasicAppModule)); Create an upgrade_adapter.ts file
  • 31. Usage Downgrade an Angular 2 Component to use it in your Angular 1 App, add in your module file : For a service : .directive(‘home’, <angular.IDirectiveFactory> upgradeAdapter.downgradeNg2Component(HomeComponent)) .factory(‘example’, adapter.downgradeNg2Provider(Example));
  • 32. Controller Migration - Remove the IIFE - Remove the $inject - Use the @Component annotation - Replace controller function by class
  • 33. Controller Migration import { Component, OnInit, Inject } from '@angular/core'; import { StateService } from "ui-router-ng2"; import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; import { Account, LoginModalService, Principal } from "../shared"; @Component({ selector: 'home', templateUrl: './home.html' }) export class HomeComponent implements OnInit { account: Account; modalRef: NgbModalRef; constructor( private principal: Principal, private $state: StateService, private loginModalService: LoginModalService ) {} ngOnInit() { this.principal.identity().then((account) => { this.account = account; }); } isAuthenticated() { return this.principal.isAuthenticated(); } login() { this.modalRef = this.loginModalService.open(); } } (function() { 'use strict'; angular .module('ng2FinalApp') .controller('HomeController', HomeController); HomeController.$inject = ['$scope', 'Principal', 'LoginService', '$state']; function HomeController ($scope, Principal, LoginService, $state) { var vm = this; vm.account = null; vm.isAuthenticated = null; vm.login = LoginService.open; vm.register = register; $scope.$on('authenticationSuccess', function() { getAccount(); }); getAccount(); function getAccount() { Principal.identity().then(function(account) { vm.account = account; vm.isAuthenticated = Principal.isAuthenticated; }); } function register () { $state.go('register'); } } })();
  • 34. Same refactoring as controllers Add your service in the providers array of your Angular 2 Module in order to inject it in your Angular 2 Components Downgrade it using the upgradeAdapter in your Angular 1 Module : Service migration .factory('example', adapter.downgradeNg2Provider(Example));
  • 35. Service Migration 1 2 (function() { 'use strict'; angular .module('ng2FinalApp') .factory('LogsService', LogsService); LogsService.$inject = ['$resource']; function LogsService ($resource) { var service = $resource('management/jhipster/logs', {}, { 'findAll': { method: 'GET', isArray: true}, 'changeLevel': { method: 'PUT'} }); return service; } })(); import { Injectable } from '@angular/core'; import { Http, Response } from '@angular/http'; import { Observable } from 'rxjs/Rx'; import { Log } from './log.model'; @Injectable() export class LogsService { constructor(private http: Http) { } changeLevel(log: Log): Observable<Response> { return this.http.put('management/jhipster/logs', log); } findAll(): Observable<Log[]> { return this.http.get('management/jhipster/logs').map((res: Response) => res.json()); } }
  • 36. Angular 1 Dependency in Angular 2 ? Upgrade the Angular 1 provider in your module file, using the upgradeAdapter: Use the @Inject annotation in your Angular 2 controller/service constructor : Same for Angular 1 lib dependencies ($state, $rootScope… ) @Inject('heroes') heroes: HeroesService adapter.upgradeNg1Provider('heroes');
  • 37. Routes Migration Angular 2 Router UI-Router NG2 Default solution for Angular Team Inspired by AngularJS UI Router Component Oriented Easy migration from UI Router NG 1 Visualizer feature Breaking changes from UI Router NG1 Not the official Solution Final Decision : UI-Router NG2, because of their contribution to JHipster NG2 Router or UI-Router ?
  • 38. Route Migration: Setup Install ui-router-ng1-to-ng2 and ui-router-ng2 NPM packages Add uirouter.upgrade module dependency in your Angular 1 Module Add Ng1ToNg2Module in your Angular 2 Module let ng1module = angular.module("myApp", [uiRouter, 'ui.router.upgrade']); @NgModule({ imports: [ BrowserModule, Ng1ToNg2Module ] }) class SampleAppModule {}
  • 39. Route Migration : UpgradeAdapter In your upgrade_adapter.ts file, add these lines : import { uiRouterNgUpgrade } from "ui-router-ng1-to-ng2"; uiRouterNgUpgrade.setUpgradeAdapter(upgradeAdapter);
  • 40. Route migration : refactoring import { RegisterComponent } from './register.component'; import { JhiLanguageService } from '../../shared'; export const registerState = { name: 'register', parent: 'account', url: '/register', data: { authorities: [], pageTitle: 'register.title' }, views: { 'content@': { component: RegisterComponent } }, resolve: [{ token: 'translate', deps: [JhiLanguageService], resolveFn: (languageService) => languageService.setLocations(['register']) }] }; (function() { 'use strict'; angular .module('ng2FinalApp') .config(stateConfig); stateConfig.$inject = ['$stateProvider']; function stateConfig($stateProvider) { $stateProvider.state('register', { parent: 'account', url: '/register', data: { authorities: [], pageTitle: 'register.title' }, views: { 'content@': { templateUrl: 'app/account/register/register.html', controller: 'RegisterController', controllerAs: 'vm' } }, resolve: { translatePartialLoader: ['$translate', '$translatePartialLoader', function ($translate, $translatePartialLoader) { $translatePartialLoader.addPart('register'); return $translate.refresh(); }] } }); } })();
  • 41. Route migration : Route Declaration let ACCOUNT_STATES = [ accountState, activateState, passwordState, finishResetState, requestResetState, registerState, sessionsState, settingsState ]; @NgModule({ imports: [ Ng2BasicSharedModule, UIRouterModule.forChild({ states: ACCOUNT_STATES }) ], declarations: [ ActivateComponent, RegisterComponent, PasswordComponent, PasswordResetInitComponent, PasswordResetFinishComponent, SessionsComponent, SettingsComponent ], providers: [ SessionsService, Register, Activate, Password, PasswordResetInit, PasswordResetFinish ], schemas: [CUSTOM_ELEMENTS_SCHEMA] }) export class Ng2BasicAccountModule {} Add your routes in a variable and then import them using UIRouterModule.forChild :
  • 42. Templates migration ng-class [ngClass] ng-click (click) ng-if *ngIf ng-model [(ngModel)] ng-repeat *ngFor AngularJS Angular 2
  • 43. Templates migration <div class="modal-header"> <button class="close" type="button" (click)="activeModal.dismiss('closed')">x </button> <h4 class="modal-title">Sign in</h4> </div> <div class="modal-body"> <div class="row"> <div class="col-md-4 col-md-offset-4"> <h1 jhi-translate="login.title">Sign in</h1> </div> <div class="col-md-8 col-md-offset-2"> <div class="alert-danger" *ngIf="authenticationError"> <strong>Failed to sign in!</strong> </div> </div> <div class="col-md-8 col-md-offset-2"> <form class="form" role="form" (ngSubmit)="login()"> <div class="form-group"> <label for="username">Login</label> <input type="text" class="form-control" name="username" id="username" [(ngModel)]="username"> </div> <div class="modal-header"> <button type="button" class="close" ng-click="vm.cancel()">&times;</button> <h4 class="modal-title">Sign in</h4> </div> <div class="modal-body"> <div class="row"> <div class="col-md-4 col-md-offset-4"> <h1 data-translate="login.title">Sign in</h1> </div> <div class="col-md-8 col-md-offset-2"> <div class="alert-danger" ng-show="vm.authenticationError"> <strong>Failed to sign in!</strong> </div> </div> <div class="col-md-8 col-md-offset-2"> <form class="form" role="form" ng-submit="vm.login($event)"> <div class="form-group"> <label for="username">Login</label> <input type="text" class="form-control" id="username" ng-model="vm.username"> </div>
  • 44. Dependencies migration - angular-ui ng-bootstrap- angular-translate ng2-translate Some external dependencies needed to be replaced/updated: - ...
  • 45. Remove AngularJS - Remove upgradeAdapter - Remove all AngularJS files Once everything has been migrated:
  • 47. Migration Feedback A lot of new technologies and architectures Difficult process Some libs are poorly documented and in alpha Only a few projects already migrated Many different choices (Router, Module Loader) Don’t do it yourself : Use JHipster ;-)
  • 48. About Angular 2... Modern approach (Component oriented) TypeScript Features (types, ES6) Cleaner code Less tools (only NPM)
  • 49. What’s next ? Router discussions Hot Module Loader Ahead Of Time compilation Finish migration for all configurations
  • 50. Demo

Editor's Notes

  1. TODO : choisir un GIF