Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
[PL] Historia jednej migracji
Search
Przemek
January 10, 2018
Technology
32
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
[PL] Historia jednej migracji
Migrating to Angular 5 - lessons learned.
Przemek
January 10, 2018
More Decks by Przemek
See All by Przemek
[PL] O blogowaniu w branży IT
psmyrdek
0
33
[PL] Jak spać spokojnie zajmując się front-endem
psmyrdek
0
33
Angular2 + TypeScript, or where is front-end development going to?
psmyrdek
0
82
[PL] ITLearning - e-elearning portal for IT Industry
psmyrdek
0
72
[PL] Not-so-object-oriented programming
psmyrdek
0
79
Untwisted - Imagine Cup 2015
psmyrdek
0
51
[PL] Interfaces 101
psmyrdek
0
1.4k
Other Decks in Technology
See All in Technology
触りたくないデータに、どう触るか AI時代のRBACアクセスガバナンス
ivry_presentationmaterials
0
270
USB PDを使ってスマホを労わりたい
raspython3
0
180
DWH の限界突破! AI エージェント向け爆速リアルタイムデータ基盤 ClickHouse
jozono
1
480
LambdaWebFunctionsを試してみた / exploring-lambda-web-functions
koukihosaka
1
350
遠藤な_めぐろLT #38 「社内のAI活用推進」@麻布台_20261009
endonanana
0
140
AI × アーキテクト 第1・2章|生成AIの課題とアーキテクトの素養
daidaidai
0
170
スキマバイトという雇用形態は存在しないので、雇用期間1日のアルバイト契約を事業者とワーカーが結ぶ手続きを支えるのがタイミーなんです
akitoshiga
0
200
Conditional PED-ANOVA: Hyperparameter Importance in Hierarchical & Dynamic Search Spaces
pfn
PRO
0
140
Refining Active Record
shugo
0
160
古い指輪から広がった JAVA コミュニティ とのつながり
yamad
0
130
DGX Spark でどこまでハッキングができるのか?
kash1064
3
1.3k
オントロジーって 結局なにもの? AI エージェントに「意味」を渡す知識設計の話
greenmidori
0
230
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
630
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
Un-Boring Meetings
codingconduct
0
460
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
2
2k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
330
Color Theory Basics | Prateek | Gurzu
gurzu
1
490
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
The browser strikes back
jonoalderson
0
1.8k
Building an army of robots
kneath
307
47k
Transcript
Przemek Smyrdek „Historia jednej migracji” [PL] 2018-01-10 @psmyrdek
None
Gotowy na 2018 TypeScript Ulepszony build system Angular CLI Angular
Universal AOT, etc…
None
None
15 minut później
✔ Gotowe
None
Przepis na migrację?
None
Pogoda Sprzęt Człowiek
Front-End @
None
SaaS vs Software House
”Na horyzoncie są inne projekty…” ”Trzeba spojrzeć na XYZ” ”Mógłbyś
sprawdzić…”
None
Ruszamy!
…ale w jaki sposób zabrać się za migrację aplikacji na
produkcji?
1. Projekt oparty o AngularJS 3. Projekt oparty o Angulara
2. Etap przejściowy - aplikacja hybrydowa
npm install @angular/upgrade --save
@angular/upgrade Integracja dwóch wersji Angulara Dependency Injection Change Detection Komponenty
@angular/upgrade Integracja dwóch wersji Angulara
None
Która część aplikacji należy do mnie?
Podejście „bottom-up” (lite upgrade) Migracja przeprowadzana „od dołu” AngularJS ->
Angular downgradeModule, downgradeComponent ☎
Podejście „top-down” (full upgrade) Migracja przeprowadzana „od góry” Angular ->
AngularJS UpgradeModule, UpgradeComponent
Migracja w moim przypadku (full): root component należy do mnie
chcę przemigrować co tylko możliwe części nienależące do mnie integruję poprzez upgrade
None
None
Jak pogodzić dwa frameworki w jednym projekcie?
client-app server-app AngularJS JavaScript Webpack node.js serwowanie plików statycznych +
Angular + TypeScript + dodatki
315 zmienionych plików prawie 8.5k dodanych linii kodu 29 commitów
„ng bootstrap”
„Spike”
client-app server-app AngularJS JavaScript Webpack node.js serwowanie plików statycznych Angular
(Angular CLI) odrębny projekt npm ignore client-app-next
client-app server-app client-app-next AngularJS bundle
client-app server-app client-app-next ng build --watch nodemon app.js
server-app client-app-next client-app
⛺ Bootstrap Jak przejść ostatni etap
<body ng-app="people-ui"> ... </body> angular.element(() => { angular.bootstrap(document, ['people-ui']); });
Od ng-app do angular.bootstrap
UpgradeModule w akcji import { UpgradeModule } from '@angular/upgrade/static'; @NgModule({
… }) export class AppModule { constructor( private upgradeModule: UpgradeModule ) { } ngDoBootstrap() { this.upgradeModule .bootstrap(document.body, ['people-ui']); } }
⛺ ⛺Serwisy Bootstrap Jak przejść ostatni etap
Migracja serwisów angular.module('people-ui') .service('QueryService', QueryService); function QueryService() { this.getFiltersQuery =
function(currentState) { return { aggregations: getCurrentState(), query: getAdditionalQueryProperties() }; } }
Migracja serwisów import { Injectable } from '@angular/core'; @Injectable() export
class QueryService { getFiltersQuery(currentState) { return { aggregations: this.getAggregations(), query: this.getQuery() }; } }
A jeśli serwis nie należy do mnie? import { InjectionToken
} from "@angular/core"; export const ACCESS_SERVICE_TOKEN = new InjectionToken<any>('ACCESS_SERVICE'); export const accessServiceProvider = { provide: ACCESS_SERVICE_TOKEN, deps: ['$injector'], useFactory: injector => injector.get('accessService') }
A jeśli serwis nie należy do mnie? import { Injectable
} from '@angular/core'; @Injectable() export class WantToUseAngularJsService { constructor( @Inject(ACCESS_SERVICE_TOKEN) private service: any ) { } }
A jeśli serwis nie należy do mnie? @NgModule({ imports: [
CommonModule ], providers: [ accessServiceProvider ] }) export class AngularJsModule { }
⛺ ⛺ ⛺ Komponenty Serwisy Bootstrap Jak przejść ostatni etap
Migracja komponentów angular .module('people-ui') .component('myComponent', { template: require('./my.component.pug'), controller: MyComponentController
});
Migracja komponentów function MyComponentController() { var ctrl = this; ctrl.$onInit
= function () { } ctrl.$onDestroy = function() { } }
Migracja komponentów @Component({ selector: 'my-component', templateUrl: './my.component.html', }) export class
MyComponent implements OnInit, OnDestroy { ngOnInit() { } ngOnDestroy() { } }
Jeszcze tylko template…
None
Jeszcze tylko template…
A nie, spoko… const { transformTemplate } = require('create-angular-template') const
angularTemplate = transformTemplate(template, options) npm install create-angular-template
psmyrdek/create-angular-template
A to?! <sr-old-component color="$ctrl.currentColor"> ... </sr-old-component>
<app-old-component /> UpgradeComponent <sr-old-component />
UpgradeComponent @Directive({ selector: 'app-old-component' }) export class OldComponentFacade extends UpgradeComponent
{ @Input() color: string; constructor(elementRef: ElementRef, injector: Injector) { super('srOldComponent', elementRef, injector); } }
AngularJS - upgraded <sr-old-component color="$ctrl.currentColor"> ... </sr-old-component> <app-old-component [color]="currentColor"> ...
</app-old-component>
⛺ Jak przejść ostatni etap ⛺ ⛺ ⛺ Komponenty Serwisy
Dyrektywy Bootstrap
Co z dyrektywami? To zależy. <sr-old-component color="$ctrl.color" popover=”$ctrl.label"> ... </sr-old-component>
Połączenie dwóch Angularów? <app-old-component [color]="color" popover="label"> ... </app-old-component> + =
Facade/Wrapper @Directive({ selector: 'app-popover' }) export class PopoverFacade extends UpgradeComponent
{ @Input() label: string; constructor(elementRef: ElementRef, injector: Injector) { super(’srPopoverFacade', elementRef, injector); } }
Co w środku? <span popover="$ctrl.label"> <ng-transclude></ng-transclude> </span> angular .module('people-ui') .component('srPopoverFacade',
{ template: ..., bindings: { label: '<’ } });
Facade/Wrapper <app-popover [label]="label"> <app-old-component [color]="color"> ... </app-old-component> </app-popover> + =
Co z dyrektywami? To zależy. Facade/Wrapper Własna implementacja Zewnętrzna biblioteka
⛺ ⛺ ⛺ ⛺ Komponenty Serwisy Dyrektywy Bootstrap Jak przejść
ostatni etap
Ciąg dalszy nastąpi… Refaktoryzacja kodu Optymalizacja aplikacji Aktualizacja zależności
None
AngularJS -> Angular-less Organizacja kodu Tooling
Przepis na migrację?
Pogoda -> Czas Sprzęt -> Środowisko Człowiek -> Zespół
None
The End