Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
[PL] Historia jednej migracji
Search
Przemek
January 10, 2018
Technology
0
27
[PL] Historia jednej migracji
Migrating to Angular 5 - lessons learned.
Przemek
January 10, 2018
Tweet
Share
More Decks by Przemek
See All by Przemek
[PL] O blogowaniu w branży IT
psmyrdek
0
30
[PL] Jak spać spokojnie zajmując się front-endem
psmyrdek
0
29
Angular2 + TypeScript, or where is front-end development going to?
psmyrdek
0
74
[PL] ITLearning - e-elearning portal for IT Industry
psmyrdek
0
65
[PL] Not-so-object-oriented programming
psmyrdek
0
70
Untwisted - Imagine Cup 2015
psmyrdek
0
46
[PL] Interfaces 101
psmyrdek
0
1.4k
Other Decks in Technology
See All in Technology
EMからICへ、二周目人材としてAI全振りのプロダクト開発で見つけた武器
yug1224
3
380
Evolution of Claude Code & How to use features
oikon48
0
150
ソフトウェアアーキテクトのための意思決定術: Create Decision Readiness—The Real Skill Behind Architectural Decision
snoozer05
PRO
29
9k
Devinを導入したら予想外の人たちに好評だった
tomuro
0
880
A Gentle Introduction to Transformers
keio_smilab
PRO
1
120
OSSで構築するIT基盤管理実践事例: NetBox・Snipe-IT・FreeRADIUS+PrivacyIDEA / Practical Case Studies of IT Infrastructure Management Using OSS
nttcom
0
200
トップマネジメントとコンピテンシーから考えるエンジニアリングマネジメント
zigorou
3
530
「使いにくい」も「運用疲れ」も卒業する UIデザイナーとエンジニアが創る持続可能な内製開発
nrinetcom
PRO
1
780
Exadata Fleet Update
oracle4engineer
PRO
0
1.3k
問い合わせ自動化の技術的挑戦
recruitengineers
PRO
2
150
Webアクセシビリティ技術と実装の実際
tomokusaba
0
210
マネージャー版 "提案のレベル" を上げる
konifar
17
12k
Featured
See All Featured
Darren the Foodie - Storyboard
khoart
PRO
3
2.7k
Building the Perfect Custom Keyboard
takai
2
710
Rails Girls Zürich Keynote
gr2m
96
14k
4 Signs Your Business is Dying
shpigford
187
22k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.1k
Design in an AI World
tapps
0
160
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
190
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
190
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.1k
Amusing Abliteration
ianozsvald
0
120
The agentic SEO stack - context over prompts
schlessera
0
680
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