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
25
[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
25
[PL] Jak spać spokojnie zajmując się front-endem
psmyrdek
0
25
Angular2 + TypeScript, or where is front-end development going to?
psmyrdek
0
71
[PL] ITLearning - e-elearning portal for IT Industry
psmyrdek
0
62
[PL] Not-so-object-oriented programming
psmyrdek
0
66
Untwisted - Imagine Cup 2015
psmyrdek
0
43
[PL] Interfaces 101
psmyrdek
0
1.4k
Other Decks in Technology
See All in Technology
バイブスに「型」を!Kent Beckに学ぶ、AI時代のテスト駆動開発
amixedcolor
3
590
「その開発、認知負荷高すぎませんか?」Platform Engineeringで始める開発者体験カイゼン術
sansantech
PRO
2
890
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
8.8k
Autonomous Database - Dedicated 技術詳細 / adb-d_technical_detail_jp
oracle4engineer
PRO
4
10k
Claude Code でアプリ開発をオートパイロットにするためのTips集 Zennの場合 / Claude Code Tips in Zenn
wadayusuke
5
1.9k
LLM時代のパフォーマンスチューニング:MongoDB運用で試したコンテキスト活用の工夫
ishikawa_pro
0
170
Modern Linux
oracle4engineer
PRO
0
160
会社紹介資料 / Sansan Company Profile
sansan33
PRO
7
380k
「全員プロダクトマネージャー」を実現する、Cursorによる仕様検討の自動運転
applism118
22
12k
slog.Handlerのよくある実装ミス
sakiengineer
4
480
Snowflake Intelligence × Document AIで“使いにくいデータ”を“使えるデータ”に
kevinrobot34
1
120
いま注目のAIエージェントを作ってみよう
supermarimobros
0
360
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
18
1.1k
Practical Orchestrator
shlominoach
190
11k
jQuery: Nuts, Bolts and Bling
dougneiner
64
7.9k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.6k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Agile that works and the tools we love
rasmusluckow
330
21k
Unsuck your backbone
ammeep
671
58k
Intergalactic Javascript Robots from Outer Space
tanoku
272
27k
Building an army of robots
kneath
306
46k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
131
19k
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