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
パスキーの自動テストはどこまでいけるのか
teamlab
PRO
0
270
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
1
460
今さら理解するウェブフォントver.2026
takanorip
3
890
エンタメ企業のM&Aを支えるデータ基盤 ― 統合から店舗のリアルタイム分析まで / Data Engineering Summit 2026
genda
0
190
AI時代のPRレビューにどう向き合うか?
kairim0
1
240
Rust で関数型ドメインモデリング
takonda
0
160
DWH の限界突破! AI エージェント向け爆速リアルタイムデータ基盤 ClickHouse
jozono
1
480
Getting Started with Google Antigravity
glaforge
0
320
S3 Filesで挑む! 八戸せんべい汁の食べ頃問題
usanchuu
0
110
AIにシークレットを見せない、WSL2で安全な開発環境
yazm
0
310
Persisting Massive Data with Rails ~Designing for 60 billion rows, and fighting the bottlenecks~ Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
0
730
「Docker Desktop不要の時代」は 来たのか?
ueponx
0
800
Featured
See All Featured
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
310
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
Building a Scalable Design System with Sketch
lauravandoore
464
34k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
410
sira's awesome portfolio website redesign presentation
elsirapls
0
460
Why Our Code Smells
bkeepers
PRO
340
58k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.4k
Darren the Foodie - Storyboard
khoart
PRO
4
4k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
540
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
640
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.4k
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