SlideShare a Scribd company logo
1 of 83
Angular in a
Microservices
world
Brecht Billiet
@brechtbilliet
Hi, I’m Brecht! I help
companies with web
technologies...
@brechtbilliet
I... A few references...
» Kickstart projects
» Give trainings/workshops
» Coach companies
» Do code-reviews
» Do audits
» Blog about stuff
http://blog.brecht.io
» Talk on meetups
» Help with architectural
decisions
@brechtbilliet
The structural evolution of web
software
@brechtbilliet
Web application
Frontend + Backend
(server-side rendering)
@brechtbilliet
We can do
this!
Web application
Frontend + Backend
(server-side rendering)
@brechtbilliet
We can do
this!
We can
still do
this!
Web application
Frontend + Backend
(server-side rendering)
@brechtbilliet
We can do
this!
We can
still do
this!
Err...
Web application
Frontend + Backend
(server-side rendering)
@brechtbilliet
Frontend Web application
(spa)
REST
Backend Web application
@brechtbilliet
We can do
this!
We can do
this!
REST
Backend Web application
Frontend Web application
(spa)
@brechtbilliet
We can
still do
this!
We can do
this!
We can do
this!
REST
Backend Web application
We can
still do
this!
Frontend Web application
(spa)
@brechtbilliet
We can
still do
this!
We can do
this!
We can do
this!
REST
Backend Web application
We can
still do
this!
Err...
Err...
Frontend Web application
(spa)
@brechtbilliet
Spotify engineering culture
» Autonomous teams
» Every team has its own
⋄ Ownership
⋄ Codebase
⋄ Build process
⋄ Deployment
» Choice of tech-stack
» Checkout these movies
» https://labs.spotify.com/
2014/03/27/spotify-
engineering-culture-part-
1/
» https://labs.spotify.com/
2014/09/20/spotify-
engineering-culture-part-
2/
@brechtbilliet
Spotify engineering culture
@brechtbilliet
Spotify engineering culture
» Hard to achieve on monoliths
Frontend monolith
REST
Backend monolith
@brechtbilliet
Frontend Web application
REST
Micro
Service
A
Micro
Service
Z
...
» Microservices
» https://martinfowler.com/articles/
microservices.html
This fixes all of the “Spotify engineering
culture” requirements
@brechtbilliet
Microservices
Frontend Web application
REST
Micro
Service
A
Micro
Service
Z
We can do
this!
We can do
this!
...
@brechtbilliet
Frontend Web application
REST
Micro
Service
A
Micro
Service
Z
...
Every team has
Its own ownership
Its code decoupled from the
rest
Its own codebase
Its own repository
Its own build process
@brechtbilliet
Frontend Web application
REST
Micro
Service
A
Micro
Service
Z
...
The frontend is still a monolith
@brechtbilliet
We want
» Code splitting
» Code sharing
» Decoupling
» Lazy loading
» Separate codebases
» To divide work in
different teams
» To give ownership to
specific teams
@brechtbilliet
Frontend Web application
REST
Micro
Service
A
Micro
Service
Z
...
We do still want a SPA (ux)
@brechtbilliet
Frontend Web application
REST
Micro
Service
A
Micro
Service
Z
...
SPA
module
A
But also want to give teams
ownership
SPA
module
Z
...
@brechtbilliet
Solution one
The iframe spa
@brechtbilliet
Did he say, IFRAMES?
@brechtbilliet
There are advantages
@brechtbilliet
Iframe 1:
This belongs to team
A. It contains enough
code and business
logic to deserve its
own project
@brechtbilliet
Iframe 2:
This belongs to team
B. This will be an even
bigger application
@brechtbilliet
Iframe 3:
This belongs to team
C. This app will be
very specific
@brechtbilliet
Orchestrator app:
This application will
only do communication
@brechtbilliet
<!doctype html>
<html>
<head>
</head>
<body>
<iframe src="http://myapp.com/search"></iframe>
<iframe src="http://myapp.com/main"></iframe>
<iframe src="http://myapp.com/player"></iframe>
</body>
</html>
@brechtbilliet
How to communicate between the
iframes
// send a message from iframe to the orchestrator app for communication
window.parent.postMessage({type: 'PLAY_SONG', data: {'title': 'Michael Jackson -
Billy Jean'}}, '*');
@brechtbilliet
How to communicate between the
iframes
// send a message from iframe to the orchestrator app for communication
window.parent.postMessage({type: 'PLAY_SONG', data: {'title': 'Michael Jackson -
Billy Jean'}}, '*');
// send a message to the orchestrator app for communication
window.addEventListener('message', receiveMessage, false);
function receiveMessage(msg): void {
switch(event.data.type){
case 'PLAY_SONG':
// todo (set some label or whatever)
}
@brechtbilliet
Reactive is cooler =)
// get a stream from all messages
postMessage$ = Observable.fromEvent(window, 'message').map(res => res.data);
// get a stream of the 'PLAY_SONG' messages
playSongMessage$ = postMessage$.filter(item => item.type === 'PLAY_SONG');
@brechtbilliet
Advantages
» Great isolation of code => assign to specific
teams
» Not tied to specific framework
» Works with all different javascript technologies
» Independant deploys
» Ability to migrate old project easily
» Easy to plug-and-play in older projects
» AB-testing becomes a breeze
» No code conflicts
» Iframes have their own inside routing
@brechtbilliet
Tradeoffs
» Performance hit (manageable in most cases)
» CSS issues, tooltips behind the iframe, ...
» Drag and drop (can be fixed, but not native)
» Dependencies will be loaded multiple times
» Harder to share state
» Only works for block-shaped elements
@brechtbilliet
Use cases
» Legacy code bases: Add ng4 project into old app in 1 line
» Platforms
⋄ One application per tab
⋄ Multiple applications per tab
» Independant deploys of projects
Don’t overuse it!
@brechtbilliet
Summary
» Use it for specific projects (platforms, legacy
codebases)
» Becomes complex when too many shared state…
» Share backend changes over sockets
» Share state changes over document-events
@brechtbilliet
Solution two
Multiple angular apps
@brechtbilliet
@brechtbilliet
Angular app Search:
Owned by Team A.
Exposes:
● Angular application
@brechtbilliet
Angular app Main:
Owned by Team B.
Exposes:
● Angular application
@brechtbilliet
Angular app Player:
Owned by Team C.
Exposes:
● Angular app
@brechtbilliet
Orchestrator app:
This application will do
orchestrating
@brechtbilliet
How to load multiple angular
apps
Ng4 app (cli)
Ng4 app (cli)
@brechtbilliet
How to load multiple angular
apps
<!doctype html>
<html>
<head>
</head>
<body>
<!--These should come from a shared bundle-->
<script type="text/javascript" src="somesharedbundle/dist/inline.bundle.js"></script>
<!--Polyfills can only be loaded ONCE!!-->
<script type="text/javascript" src="somesharedbundle/dist/polyfills.bundle.js"></script>
...
</body>
</html>
@brechtbilliet
How to load multiple angular
apps
// create the DOM tag
document.body.appendChild(document.createElement('app-courses'));
// load the script from the dist folder
loadScriptsSync(['courses/dist/inline.bundle.js',
'courses/dist/vendor.bundle.js',
'courses/dist/main.bundle.js']);
// create the DOM tag
document.body.appendChild(document.createElement('app-users'));
// load the script from the dist folder
loadScriptsSync(['users/dist/inline.bundle.js',
'users/dist/vendor.bundle.js',
'users/dist/main.bundle.js']);
@brechtbilliet
How to load multiple angular
apps
// It’s important that the script are loaded synchronous
function loadScript(path, cb) {
var scriptTag = document.createElement('script');
scriptTag.src = path;
scriptTag.onload = cb;
scriptTag.onreadystatechange = cb;
document.body.appendChild(scriptTag);
}
function loadScriptsSync(paths) {
loadScript(paths[0], () => {
loadScriptsSync(paths.filter(item => item !== paths[0]));
});
}
@brechtbilliet
Advantages
» You don’t need iframes to load multiple angular
apps
» You can easily divide the work between teams
» Independant deploys
@brechtbilliet
Tradeoffs
» No routing inside the child-apps
» Can’t have multiple instances of a child-app
» Not completely sandboxed
» Dependencies will be loaded multiple times
@brechtbilliet
Summary
» Some people are for it, some are against it
» A personal feeling: It feels a bit hacky
» You can use it when you hit the limitations of an
iframe (e.g css)
» Routing is impossible
@brechtbilliet
Solution three
Angular modules
@brechtbilliet
@brechtbilliet
Angular module Search:
Owned by Team A.
Exposes:
● Angular module
● Example
environment
@brechtbilliet
Angular module Main:
Owned by Team B.
Exposes:
● Angular module
● Example
environment
@brechtbilliet
Angular module Player:
Owned by Team C.
Exposes:
● Angular module
● Example
environment
@brechtbilliet
Orchestrator app:
This application will do
mostly routing/lazy
loading
@brechtbilliet
Angular (>2) is made for large
apps
It’s build as a platform framework
It’s build for large teams (typescript, modules, DI)
Provides:
» Modules with great encapsulation
» Lazy loading
» Ahead-of-time compilation
» A CLI (to reduce the setup process to a minimum)
@brechtbilliet
Spotify-application
(orchestrator)
(angular application)
Search
(angular module)
Main
(angular module)
Player
(angular module)
Splitting up code to specific
teams
NPM
package
NPM
package
NPM
package
@brechtbilliet
Spotify-application
(orchestrator)
(angular application)
Search
(angular module)
Main
(angular module)
Player
(angular module)
Can be TS modules
as well...
NPM
package
NPM
package
NPM
package
Other x
(TS module)
Other y
(TS module)
NPM
package
NPM
package
@brechtbilliet
What does a module look like?
Every module has
» Its own package.json
» Its own build process
» Its own test
environment
» Its own versions
» Its own test suite
» Its own repo
(debatable)
So we can:
» Assign a specific team
» Have separate deploy
to specific NPM
registry
» Lazy load them
@brechtbilliet
The orchestration App:
Module
...
import { routing } from './routes';
import { SpotifySearchModule } from '@spotify-app/spotify-search'; // Npm package
import { SpotifyPlayerModule } from '@spotify-app/spotify-player'; // Npm package
@NgModule({
...
imports: [
routing, // here we lazy load our modules
SpotifySearchModule, // directly import the angular module from npm
SpotifyPlayerModule, // directly import the angular module from npm
BrowserModule,
...
]
})
export class MainModule {
The orchestration App:
Routing
import { PreloadAllModules, RouterModule } from '@angular/router';
export const routes = [
{
path: 'foo',
loadChildren: '../node_modules/@spotify-app/foo/#SpotifyFooModule'
},
{
path: 'bar',
loadChildren: '../node_modules/@spotify-app/bar/#SpotifyBarModule'
}
];
export const routing = RouterModule.forRoot(routes, {
preloadingStrategy: PreloadAllModules });
@brechtbilliet
Creating a child-module
» ng new spotify-player
» Rename src to testenv
» Create folder src, and move the source code there
» Change the .angular-cli.json root property in “app”
to “testenv”
@brechtbilliet
Just use the source code (no
build)
» Set the Package.json main property to src/index.js
index.js:
export {AppModule} from './app/app.module';
@brechtbilliet
Advantages
» Lazy loading out of the box
» Module system out of the box
» Creating projects is easy with the CLI
» Routing + child-routing works perfectly
@brechtbilliet
Tradeoffs
» For every module deploy you also have to deploy
the root application
» Bound to a framework (debatable)
» Not easy to combine with AOT
» Not completely sandboxed, but angular provides
great encapsulation
@brechtbilliet
Last solution
Bootstrap components
@brechtbilliet
@brechtbilliet
Angular component
Search:
Owned by Team A.
Exposed by Angular module
Search
@brechtbilliet
Angular component Main:
Owned by Team B.
Exposed by Angular module
Main
@brechtbilliet
Angular component Player:
Owned by Team C. Exposed
by Angular module Player
@brechtbilliet
App (tech stack
doesn’t matter)
@brechtbilliet
Angular 1 app
<search>
</search>
<main>
</main>
<player></player>
Angular 4 app - spotify
@brechtbilliet
Use multiple bootstrap
components
<!doctype html>
<html>
<head>
</head>
<body>
<spotify-search>Loading search...</spotify-search>
<spotify-main>Loading main...</spotify-main>
<spotify-player>Loading player...</spotify-player>
</body>
</html>
@brechtbilliet
Use multiple bootstrap
components
@NgModule({
...
declarations: [SearchComponent, MainComponent, PlayerComponent],
imports: [BrowserModule],
bootstrap: [SearchComponent, MainComponent, PlayerComponent]
})
export class AppModule {
}
@brechtbilliet
Divide in teams again =)
import { SearchModule } from '@spotify-app/spotify-search';
import { MainModule } from '@spotify-app/spotify-main';
import { PlayerModule } from '@spotify-app/spotify-player';
@NgModule({
...
imports: [BrowserModule, SpotifySearchModule, SpotifyMainModule, SpotifyPlayerModule],
bootstrap: [SearchComponent, MainComponent, PlayerComponent]
})
export class AppModule {
}
@brechtbilliet
Advantages
» You can use multiple ng4 apps (as components) in
a non angular application
» You can combine it with the angular modules
approach (same advantages)
@brechtbilliet
Tradeoffs
» Iframes still provide better encapsulation
» No independant deploys (only to npm)
@brechtbilliet
Summary
» For me this is the most ideal solution
@brechtbilliet
Questions
Shoot!
@brechtbilliet
@brechtbilliet
Credits
This template is free to use under Creative Commons Attribution license.
Thank you 4 having me!
@brechtbilliet
https://www.linkedin.com/in/brecht-billiet-58417426/
billietbrecht@gmail.com
http://brecht.io
http://blog.brecht.io
http://strongbrew.io
@brechtbilliet

More Related Content

What's hot

RDRA DDD Agile
RDRA DDD AgileRDRA DDD Agile
RDRA DDD Agile増田 亨
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAgile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAraf Karsh Hamid
 
ID連携のあるとき~、ないとき~ #エンプラ編
ID連携のあるとき~、ないとき~ #エンプラ編ID連携のあるとき~、ないとき~ #エンプラ編
ID連携のあるとき~、ないとき~ #エンプラ編Takashi Yahata
 
Get started with GitHub Copilot.pptx
Get started with GitHub Copilot.pptxGet started with GitHub Copilot.pptx
Get started with GitHub Copilot.pptxKhushiPanwar33
 
境界付けられたコンテキスト 概念編 (ドメイン駆動設計用語解説シリーズ)
境界付けられたコンテキスト 概念編 (ドメイン駆動設計用語解説シリーズ)境界付けられたコンテキスト 概念編 (ドメイン駆動設計用語解説シリーズ)
境界付けられたコンテキスト 概念編 (ドメイン駆動設計用語解説シリーズ)Koichiro Matsuoka
 
What Is Platform as a Product - Clues from Team Topologies @ AXA, Sep 2021
What Is Platform as a Product - Clues from Team Topologies @ AXA, Sep 2021What Is Platform as a Product - Clues from Team Topologies @ AXA, Sep 2021
What Is Platform as a Product - Clues from Team Topologies @ AXA, Sep 2021Manuel Pais
 
How to Choose the Proper Infra (Online, Odoo.sh, On premise)
How to Choose the Proper Infra (Online, Odoo.sh, On premise)How to Choose the Proper Infra (Online, Odoo.sh, On premise)
How to Choose the Proper Infra (Online, Odoo.sh, On premise)Odoo
 
[devops REX 2017] Days of Chaos : le développement de la culture devops chez ...
[devops REX 2017] Days of Chaos : le développement de la culture devops chez ...[devops REX 2017] Days of Chaos : le développement de la culture devops chez ...
[devops REX 2017] Days of Chaos : le développement de la culture devops chez ...devops REX
 
始めよう! ドメイン駆動設計&マイクロサービス開発 ~C# と Azure Service Fabric で最高の DDD 開発を~
始めよう! ドメイン駆動設計&マイクロサービス開発 ~C# と Azure Service Fabric で最高の DDD 開発を~始めよう! ドメイン駆動設計&マイクロサービス開発 ~C# と Azure Service Fabric で最高の DDD 開発を~
始めよう! ドメイン駆動設計&マイクロサービス開発 ~C# と Azure Service Fabric で最高の DDD 開発を~貴志 上坂
 
Scaling Agile in Regulated Environments: Addressing the Challenges of Complia...
Scaling Agile in Regulated Environments: Addressing the Challenges of Complia...Scaling Agile in Regulated Environments: Addressing the Challenges of Complia...
Scaling Agile in Regulated Environments: Addressing the Challenges of Complia...Cprime
 
Atlassian confluence WIKI를 활용한 공유와 협업 환경 구성
Atlassian confluence WIKI를 활용한 공유와 협업 환경 구성Atlassian confluence WIKI를 활용한 공유와 협업 환경 구성
Atlassian confluence WIKI를 활용한 공유와 협업 환경 구성KwangSeob Jeong
 
Domain Driven Design - Strategic Patterns and Microservices
Domain Driven Design - Strategic Patterns and MicroservicesDomain Driven Design - Strategic Patterns and Microservices
Domain Driven Design - Strategic Patterns and MicroservicesRadosław Maziarka
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignAOE
 
Draft: building secure applications with keycloak (oidc/jwt)
Draft: building secure applications with keycloak (oidc/jwt)Draft: building secure applications with keycloak (oidc/jwt)
Draft: building secure applications with keycloak (oidc/jwt)Abhishek Koserwal
 
某S社のddd(メイリオ)
某S社のddd(メイリオ)某S社のddd(メイリオ)
某S社のddd(メイリオ)kumake
 
Microsoft Power Platform en Action
Microsoft Power Platform en Action Microsoft Power Platform en Action
Microsoft Power Platform en Action Denys Chamberland
 
とある情報の超整理術
とある情報の超整理術とある情報の超整理術
とある情報の超整理術Masahito Zembutsu
 

What's hot (20)

RDRA DDD Agile
RDRA DDD AgileRDRA DDD Agile
RDRA DDD Agile
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAgile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven Design
 
ID連携のあるとき~、ないとき~ #エンプラ編
ID連携のあるとき~、ないとき~ #エンプラ編ID連携のあるとき~、ないとき~ #エンプラ編
ID連携のあるとき~、ないとき~ #エンプラ編
 
Get started with GitHub Copilot.pptx
Get started with GitHub Copilot.pptxGet started with GitHub Copilot.pptx
Get started with GitHub Copilot.pptx
 
OpenID Connect 4 SSI
OpenID Connect 4 SSIOpenID Connect 4 SSI
OpenID Connect 4 SSI
 
Azure dev ops
Azure dev opsAzure dev ops
Azure dev ops
 
境界付けられたコンテキスト 概念編 (ドメイン駆動設計用語解説シリーズ)
境界付けられたコンテキスト 概念編 (ドメイン駆動設計用語解説シリーズ)境界付けられたコンテキスト 概念編 (ドメイン駆動設計用語解説シリーズ)
境界付けられたコンテキスト 概念編 (ドメイン駆動設計用語解説シリーズ)
 
What Is Platform as a Product - Clues from Team Topologies @ AXA, Sep 2021
What Is Platform as a Product - Clues from Team Topologies @ AXA, Sep 2021What Is Platform as a Product - Clues from Team Topologies @ AXA, Sep 2021
What Is Platform as a Product - Clues from Team Topologies @ AXA, Sep 2021
 
How to Choose the Proper Infra (Online, Odoo.sh, On premise)
How to Choose the Proper Infra (Online, Odoo.sh, On premise)How to Choose the Proper Infra (Online, Odoo.sh, On premise)
How to Choose the Proper Infra (Online, Odoo.sh, On premise)
 
[devops REX 2017] Days of Chaos : le développement de la culture devops chez ...
[devops REX 2017] Days of Chaos : le développement de la culture devops chez ...[devops REX 2017] Days of Chaos : le développement de la culture devops chez ...
[devops REX 2017] Days of Chaos : le développement de la culture devops chez ...
 
Scrum + bdd + ddd
Scrum + bdd + dddScrum + bdd + ddd
Scrum + bdd + ddd
 
始めよう! ドメイン駆動設計&マイクロサービス開発 ~C# と Azure Service Fabric で最高の DDD 開発を~
始めよう! ドメイン駆動設計&マイクロサービス開発 ~C# と Azure Service Fabric で最高の DDD 開発を~始めよう! ドメイン駆動設計&マイクロサービス開発 ~C# と Azure Service Fabric で最高の DDD 開発を~
始めよう! ドメイン駆動設計&マイクロサービス開発 ~C# と Azure Service Fabric で最高の DDD 開発を~
 
Scaling Agile in Regulated Environments: Addressing the Challenges of Complia...
Scaling Agile in Regulated Environments: Addressing the Challenges of Complia...Scaling Agile in Regulated Environments: Addressing the Challenges of Complia...
Scaling Agile in Regulated Environments: Addressing the Challenges of Complia...
 
Atlassian confluence WIKI를 활용한 공유와 협업 환경 구성
Atlassian confluence WIKI를 활용한 공유와 협업 환경 구성Atlassian confluence WIKI를 활용한 공유와 협업 환경 구성
Atlassian confluence WIKI를 활용한 공유와 협업 환경 구성
 
Domain Driven Design - Strategic Patterns and Microservices
Domain Driven Design - Strategic Patterns and MicroservicesDomain Driven Design - Strategic Patterns and Microservices
Domain Driven Design - Strategic Patterns and Microservices
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Draft: building secure applications with keycloak (oidc/jwt)
Draft: building secure applications with keycloak (oidc/jwt)Draft: building secure applications with keycloak (oidc/jwt)
Draft: building secure applications with keycloak (oidc/jwt)
 
某S社のddd(メイリオ)
某S社のddd(メイリオ)某S社のddd(メイリオ)
某S社のddd(メイリオ)
 
Microsoft Power Platform en Action
Microsoft Power Platform en Action Microsoft Power Platform en Action
Microsoft Power Platform en Action
 
とある情報の超整理術
とある情報の超整理術とある情報の超整理術
とある情報の超整理術
 

Similar to Agular in a microservices world

Viacheslav Eremin interview about DOT NET (eng lang)
Viacheslav Eremin interview about DOT NET (eng lang)Viacheslav Eremin interview about DOT NET (eng lang)
Viacheslav Eremin interview about DOT NET (eng lang)Viacheslav Eremin
 
MongoDB.local Atlanta: MongoDB Stitch Tutorial
MongoDB.local Atlanta: MongoDB Stitch TutorialMongoDB.local Atlanta: MongoDB Stitch Tutorial
MongoDB.local Atlanta: MongoDB Stitch TutorialMongoDB
 
Over view of Technologies
Over view of TechnologiesOver view of Technologies
Over view of TechnologiesChris Mitchell
 
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
MongoDB.local Seattle 2019: MongoDB Stitch TutorialMongoDB.local Seattle 2019: MongoDB Stitch Tutorial
MongoDB.local Seattle 2019: MongoDB Stitch TutorialMongoDB
 
MongoDB.local Dallas 2019: MongoDB Stitch Tutorial
MongoDB.local Dallas 2019: MongoDB Stitch TutorialMongoDB.local Dallas 2019: MongoDB Stitch Tutorial
MongoDB.local Dallas 2019: MongoDB Stitch TutorialMongoDB
 
Web Components
Web ComponentsWeb Components
Web ComponentsFITC
 
How to migrate large project from Angular to React
How to migrate large project from Angular to ReactHow to migrate large project from Angular to React
How to migrate large project from Angular to ReactTomasz Bak
 
Html5 today
Html5 todayHtml5 today
Html5 todayRoy Yu
 
AstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdf
AstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdfAstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdf
AstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdfFarHanWasif1
 
Designing Powerful Web Applications Using AJAX and Other RIAs
Designing Powerful Web Applications Using AJAX and Other RIAsDesigning Powerful Web Applications Using AJAX and Other RIAs
Designing Powerful Web Applications Using AJAX and Other RIAsDave Malouf
 
Building a full-stack app with Golang and Google Cloud Platform in one week
Building a full-stack app with Golang and Google Cloud Platform in one weekBuilding a full-stack app with Golang and Google Cloud Platform in one week
Building a full-stack app with Golang and Google Cloud Platform in one weekDr. Felix Raab
 
Frontend microservices: architectures and solutions
Frontend microservices: architectures and solutionsFrontend microservices: architectures and solutions
Frontend microservices: architectures and solutionsMikhail Kuznetcov
 
AOT(Ahead Of Time)
AOT(Ahead Of Time)AOT(Ahead Of Time)
AOT(Ahead Of Time)Questpond
 
Html 5 in a big nutshell
Html 5 in a big nutshellHtml 5 in a big nutshell
Html 5 in a big nutshellLennart Schoors
 
The potential in Drupal 8.x and how to realize it
The potential in Drupal 8.x and how to realize itThe potential in Drupal 8.x and how to realize it
The potential in Drupal 8.x and how to realize itAngela Byron
 
Js foo - Sept 8 upload
Js foo - Sept 8 uploadJs foo - Sept 8 upload
Js foo - Sept 8 uploadDebnath Sinha
 
Evolving Services Into A Cloud Native World
Evolving Services Into A Cloud Native WorldEvolving Services Into A Cloud Native World
Evolving Services Into A Cloud Native WorldIain Hull
 

Similar to Agular in a microservices world (20)

Viacheslav Eremin interview about DOT NET (eng lang)
Viacheslav Eremin interview about DOT NET (eng lang)Viacheslav Eremin interview about DOT NET (eng lang)
Viacheslav Eremin interview about DOT NET (eng lang)
 
MyReplayInZen
MyReplayInZenMyReplayInZen
MyReplayInZen
 
MongoDB.local Atlanta: MongoDB Stitch Tutorial
MongoDB.local Atlanta: MongoDB Stitch TutorialMongoDB.local Atlanta: MongoDB Stitch Tutorial
MongoDB.local Atlanta: MongoDB Stitch Tutorial
 
Over view of Technologies
Over view of TechnologiesOver view of Technologies
Over view of Technologies
 
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
MongoDB.local Seattle 2019: MongoDB Stitch TutorialMongoDB.local Seattle 2019: MongoDB Stitch Tutorial
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
 
Micro Front Ends : Divided We Rule by Parth Ghiya - AhmedabadJS
Micro Front Ends : Divided We Rule by Parth Ghiya - AhmedabadJSMicro Front Ends : Divided We Rule by Parth Ghiya - AhmedabadJS
Micro Front Ends : Divided We Rule by Parth Ghiya - AhmedabadJS
 
MongoDB.local Dallas 2019: MongoDB Stitch Tutorial
MongoDB.local Dallas 2019: MongoDB Stitch TutorialMongoDB.local Dallas 2019: MongoDB Stitch Tutorial
MongoDB.local Dallas 2019: MongoDB Stitch Tutorial
 
Web Components
Web ComponentsWeb Components
Web Components
 
How to migrate large project from Angular to React
How to migrate large project from Angular to ReactHow to migrate large project from Angular to React
How to migrate large project from Angular to React
 
Html5 today
Html5 todayHtml5 today
Html5 today
 
AstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdf
AstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdfAstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdf
AstroLabs_Academy_Learning_to_Code-Coding_Bootcamp_Day1.pdf
 
HBD
HBDHBD
HBD
 
Designing Powerful Web Applications Using AJAX and Other RIAs
Designing Powerful Web Applications Using AJAX and Other RIAsDesigning Powerful Web Applications Using AJAX and Other RIAs
Designing Powerful Web Applications Using AJAX and Other RIAs
 
Building a full-stack app with Golang and Google Cloud Platform in one week
Building a full-stack app with Golang and Google Cloud Platform in one weekBuilding a full-stack app with Golang and Google Cloud Platform in one week
Building a full-stack app with Golang and Google Cloud Platform in one week
 
Frontend microservices: architectures and solutions
Frontend microservices: architectures and solutionsFrontend microservices: architectures and solutions
Frontend microservices: architectures and solutions
 
AOT(Ahead Of Time)
AOT(Ahead Of Time)AOT(Ahead Of Time)
AOT(Ahead Of Time)
 
Html 5 in a big nutshell
Html 5 in a big nutshellHtml 5 in a big nutshell
Html 5 in a big nutshell
 
The potential in Drupal 8.x and how to realize it
The potential in Drupal 8.x and how to realize itThe potential in Drupal 8.x and how to realize it
The potential in Drupal 8.x and how to realize it
 
Js foo - Sept 8 upload
Js foo - Sept 8 uploadJs foo - Sept 8 upload
Js foo - Sept 8 upload
 
Evolving Services Into A Cloud Native World
Evolving Services Into A Cloud Native WorldEvolving Services Into A Cloud Native World
Evolving Services Into A Cloud Native World
 

Recently uploaded

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Agular in a microservices world

  • 2. Hi, I’m Brecht! I help companies with web technologies... @brechtbilliet
  • 3. I... A few references... » Kickstart projects » Give trainings/workshops » Coach companies » Do code-reviews » Do audits » Blog about stuff http://blog.brecht.io » Talk on meetups » Help with architectural decisions @brechtbilliet
  • 4. The structural evolution of web software @brechtbilliet
  • 5. Web application Frontend + Backend (server-side rendering) @brechtbilliet
  • 6. We can do this! Web application Frontend + Backend (server-side rendering) @brechtbilliet
  • 7. We can do this! We can still do this! Web application Frontend + Backend (server-side rendering) @brechtbilliet
  • 8. We can do this! We can still do this! Err... Web application Frontend + Backend (server-side rendering) @brechtbilliet
  • 9. Frontend Web application (spa) REST Backend Web application @brechtbilliet
  • 10. We can do this! We can do this! REST Backend Web application Frontend Web application (spa) @brechtbilliet
  • 11. We can still do this! We can do this! We can do this! REST Backend Web application We can still do this! Frontend Web application (spa) @brechtbilliet
  • 12. We can still do this! We can do this! We can do this! REST Backend Web application We can still do this! Err... Err... Frontend Web application (spa) @brechtbilliet
  • 13. Spotify engineering culture » Autonomous teams » Every team has its own ⋄ Ownership ⋄ Codebase ⋄ Build process ⋄ Deployment » Choice of tech-stack » Checkout these movies » https://labs.spotify.com/ 2014/03/27/spotify- engineering-culture-part- 1/ » https://labs.spotify.com/ 2014/09/20/spotify- engineering-culture-part- 2/ @brechtbilliet
  • 15. Spotify engineering culture » Hard to achieve on monoliths Frontend monolith REST Backend monolith @brechtbilliet
  • 16. Frontend Web application REST Micro Service A Micro Service Z ... » Microservices » https://martinfowler.com/articles/ microservices.html This fixes all of the “Spotify engineering culture” requirements @brechtbilliet Microservices
  • 17. Frontend Web application REST Micro Service A Micro Service Z We can do this! We can do this! ... @brechtbilliet
  • 18. Frontend Web application REST Micro Service A Micro Service Z ... Every team has Its own ownership Its code decoupled from the rest Its own codebase Its own repository Its own build process @brechtbilliet
  • 19. Frontend Web application REST Micro Service A Micro Service Z ... The frontend is still a monolith @brechtbilliet
  • 20. We want » Code splitting » Code sharing » Decoupling » Lazy loading » Separate codebases » To divide work in different teams » To give ownership to specific teams @brechtbilliet
  • 22. Frontend Web application REST Micro Service A Micro Service Z ... SPA module A But also want to give teams ownership SPA module Z ... @brechtbilliet
  • 23. Solution one The iframe spa @brechtbilliet
  • 24. Did he say, IFRAMES? @brechtbilliet
  • 27. Iframe 1: This belongs to team A. It contains enough code and business logic to deserve its own project @brechtbilliet
  • 28. Iframe 2: This belongs to team B. This will be an even bigger application @brechtbilliet
  • 29. Iframe 3: This belongs to team C. This app will be very specific @brechtbilliet
  • 30. Orchestrator app: This application will only do communication @brechtbilliet
  • 31. <!doctype html> <html> <head> </head> <body> <iframe src="http://myapp.com/search"></iframe> <iframe src="http://myapp.com/main"></iframe> <iframe src="http://myapp.com/player"></iframe> </body> </html> @brechtbilliet
  • 32. How to communicate between the iframes // send a message from iframe to the orchestrator app for communication window.parent.postMessage({type: 'PLAY_SONG', data: {'title': 'Michael Jackson - Billy Jean'}}, '*'); @brechtbilliet
  • 33. How to communicate between the iframes // send a message from iframe to the orchestrator app for communication window.parent.postMessage({type: 'PLAY_SONG', data: {'title': 'Michael Jackson - Billy Jean'}}, '*'); // send a message to the orchestrator app for communication window.addEventListener('message', receiveMessage, false); function receiveMessage(msg): void { switch(event.data.type){ case 'PLAY_SONG': // todo (set some label or whatever) } @brechtbilliet
  • 34. Reactive is cooler =) // get a stream from all messages postMessage$ = Observable.fromEvent(window, 'message').map(res => res.data); // get a stream of the 'PLAY_SONG' messages playSongMessage$ = postMessage$.filter(item => item.type === 'PLAY_SONG'); @brechtbilliet
  • 35. Advantages » Great isolation of code => assign to specific teams » Not tied to specific framework » Works with all different javascript technologies » Independant deploys » Ability to migrate old project easily » Easy to plug-and-play in older projects » AB-testing becomes a breeze » No code conflicts » Iframes have their own inside routing @brechtbilliet
  • 36. Tradeoffs » Performance hit (manageable in most cases) » CSS issues, tooltips behind the iframe, ... » Drag and drop (can be fixed, but not native) » Dependencies will be loaded multiple times » Harder to share state » Only works for block-shaped elements @brechtbilliet
  • 37. Use cases » Legacy code bases: Add ng4 project into old app in 1 line » Platforms ⋄ One application per tab ⋄ Multiple applications per tab » Independant deploys of projects Don’t overuse it! @brechtbilliet
  • 38. Summary » Use it for specific projects (platforms, legacy codebases) » Becomes complex when too many shared state… » Share backend changes over sockets » Share state changes over document-events @brechtbilliet
  • 39. Solution two Multiple angular apps @brechtbilliet
  • 41. Angular app Search: Owned by Team A. Exposes: ● Angular application @brechtbilliet
  • 42. Angular app Main: Owned by Team B. Exposes: ● Angular application @brechtbilliet
  • 43. Angular app Player: Owned by Team C. Exposes: ● Angular app @brechtbilliet
  • 44. Orchestrator app: This application will do orchestrating @brechtbilliet
  • 45. How to load multiple angular apps Ng4 app (cli) Ng4 app (cli) @brechtbilliet
  • 46. How to load multiple angular apps <!doctype html> <html> <head> </head> <body> <!--These should come from a shared bundle--> <script type="text/javascript" src="somesharedbundle/dist/inline.bundle.js"></script> <!--Polyfills can only be loaded ONCE!!--> <script type="text/javascript" src="somesharedbundle/dist/polyfills.bundle.js"></script> ... </body> </html> @brechtbilliet
  • 47. How to load multiple angular apps // create the DOM tag document.body.appendChild(document.createElement('app-courses')); // load the script from the dist folder loadScriptsSync(['courses/dist/inline.bundle.js', 'courses/dist/vendor.bundle.js', 'courses/dist/main.bundle.js']); // create the DOM tag document.body.appendChild(document.createElement('app-users')); // load the script from the dist folder loadScriptsSync(['users/dist/inline.bundle.js', 'users/dist/vendor.bundle.js', 'users/dist/main.bundle.js']); @brechtbilliet
  • 48. How to load multiple angular apps // It’s important that the script are loaded synchronous function loadScript(path, cb) { var scriptTag = document.createElement('script'); scriptTag.src = path; scriptTag.onload = cb; scriptTag.onreadystatechange = cb; document.body.appendChild(scriptTag); } function loadScriptsSync(paths) { loadScript(paths[0], () => { loadScriptsSync(paths.filter(item => item !== paths[0])); }); } @brechtbilliet
  • 49. Advantages » You don’t need iframes to load multiple angular apps » You can easily divide the work between teams » Independant deploys @brechtbilliet
  • 50. Tradeoffs » No routing inside the child-apps » Can’t have multiple instances of a child-app » Not completely sandboxed » Dependencies will be loaded multiple times @brechtbilliet
  • 51. Summary » Some people are for it, some are against it » A personal feeling: It feels a bit hacky » You can use it when you hit the limitations of an iframe (e.g css) » Routing is impossible @brechtbilliet
  • 54. Angular module Search: Owned by Team A. Exposes: ● Angular module ● Example environment @brechtbilliet
  • 55. Angular module Main: Owned by Team B. Exposes: ● Angular module ● Example environment @brechtbilliet
  • 56. Angular module Player: Owned by Team C. Exposes: ● Angular module ● Example environment @brechtbilliet
  • 57. Orchestrator app: This application will do mostly routing/lazy loading @brechtbilliet
  • 58. Angular (>2) is made for large apps It’s build as a platform framework It’s build for large teams (typescript, modules, DI) Provides: » Modules with great encapsulation » Lazy loading » Ahead-of-time compilation » A CLI (to reduce the setup process to a minimum) @brechtbilliet
  • 59. Spotify-application (orchestrator) (angular application) Search (angular module) Main (angular module) Player (angular module) Splitting up code to specific teams NPM package NPM package NPM package @brechtbilliet
  • 60. Spotify-application (orchestrator) (angular application) Search (angular module) Main (angular module) Player (angular module) Can be TS modules as well... NPM package NPM package NPM package Other x (TS module) Other y (TS module) NPM package NPM package @brechtbilliet
  • 61. What does a module look like? Every module has » Its own package.json » Its own build process » Its own test environment » Its own versions » Its own test suite » Its own repo (debatable) So we can: » Assign a specific team » Have separate deploy to specific NPM registry » Lazy load them @brechtbilliet
  • 62. The orchestration App: Module ... import { routing } from './routes'; import { SpotifySearchModule } from '@spotify-app/spotify-search'; // Npm package import { SpotifyPlayerModule } from '@spotify-app/spotify-player'; // Npm package @NgModule({ ... imports: [ routing, // here we lazy load our modules SpotifySearchModule, // directly import the angular module from npm SpotifyPlayerModule, // directly import the angular module from npm BrowserModule, ... ] }) export class MainModule {
  • 63. The orchestration App: Routing import { PreloadAllModules, RouterModule } from '@angular/router'; export const routes = [ { path: 'foo', loadChildren: '../node_modules/@spotify-app/foo/#SpotifyFooModule' }, { path: 'bar', loadChildren: '../node_modules/@spotify-app/bar/#SpotifyBarModule' } ]; export const routing = RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules }); @brechtbilliet
  • 64. Creating a child-module » ng new spotify-player » Rename src to testenv » Create folder src, and move the source code there » Change the .angular-cli.json root property in “app” to “testenv” @brechtbilliet
  • 65. Just use the source code (no build) » Set the Package.json main property to src/index.js index.js: export {AppModule} from './app/app.module'; @brechtbilliet
  • 66. Advantages » Lazy loading out of the box » Module system out of the box » Creating projects is easy with the CLI » Routing + child-routing works perfectly @brechtbilliet
  • 67. Tradeoffs » For every module deploy you also have to deploy the root application » Bound to a framework (debatable) » Not easy to combine with AOT » Not completely sandboxed, but angular provides great encapsulation @brechtbilliet
  • 70. Angular component Search: Owned by Team A. Exposed by Angular module Search @brechtbilliet
  • 71. Angular component Main: Owned by Team B. Exposed by Angular module Main @brechtbilliet
  • 72. Angular component Player: Owned by Team C. Exposed by Angular module Player @brechtbilliet
  • 73. App (tech stack doesn’t matter) @brechtbilliet
  • 75. Use multiple bootstrap components <!doctype html> <html> <head> </head> <body> <spotify-search>Loading search...</spotify-search> <spotify-main>Loading main...</spotify-main> <spotify-player>Loading player...</spotify-player> </body> </html> @brechtbilliet
  • 76. Use multiple bootstrap components @NgModule({ ... declarations: [SearchComponent, MainComponent, PlayerComponent], imports: [BrowserModule], bootstrap: [SearchComponent, MainComponent, PlayerComponent] }) export class AppModule { } @brechtbilliet
  • 77. Divide in teams again =) import { SearchModule } from '@spotify-app/spotify-search'; import { MainModule } from '@spotify-app/spotify-main'; import { PlayerModule } from '@spotify-app/spotify-player'; @NgModule({ ... imports: [BrowserModule, SpotifySearchModule, SpotifyMainModule, SpotifyPlayerModule], bootstrap: [SearchComponent, MainComponent, PlayerComponent] }) export class AppModule { } @brechtbilliet
  • 78. Advantages » You can use multiple ng4 apps (as components) in a non angular application » You can combine it with the angular modules approach (same advantages) @brechtbilliet
  • 79. Tradeoffs » Iframes still provide better encapsulation » No independant deploys (only to npm) @brechtbilliet
  • 80. Summary » For me this is the most ideal solution @brechtbilliet
  • 83. Credits This template is free to use under Creative Commons Attribution license. Thank you 4 having me! @brechtbilliet https://www.linkedin.com/in/brecht-billiet-58417426/ billietbrecht@gmail.com http://brecht.io http://blog.brecht.io http://strongbrew.io @brechtbilliet