Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Structure for big Angular Applications -- Packages, Monorepos & Micro Apps @AngularDays in Berlin, Oct 2018

Structure for big Angular Applications -- Packages, Monorepos & Micro Apps @AngularDays in Berlin, Oct 2018

Contains:
- npm Packages
- Monorepo
- Micro Apps

# Library Example
https://github.com/manfredsteyer/logger_lib_sample

# Monorepo Example
https://github.com/manfredsteyer/monorepo-demo

# Micro Apps Example
https://github.com/manfredsteyer/Angular_MicroApps_Different_Technologies

# More Blog-Articles & Angular Trainings
https://www.softwarearchitekt.at

Manfred Steyer

October 11, 2018
Tweet

More Decks by Manfred Steyer

Other Decks in Programming

Transcript

  1. @ManfredSteyer Structure for big Angular Applications Packages, Monorepos & Micro

    Apps Manfred Steyer SOFTWAREarchitekt.at ManfredSteyer
  2. @ManfredSteyer About me… • Manfred Steyer • SOFTWAREarchitekt.at • Angular

    Trainings and Consultancy • Google Developer Expert (GDE) Page ▪ 3 Manfred Steyer Public: Vienna, München, Zürich In-House: everywhere http://softwarearchitekt.at/workshops
  3. @ManfredSteyer Create Library with CLI >= 6 npm install -g

    @angular/cli ng new lib-project cd lib-project ng generate library flight-booking-lib ng generate application playground-app ng serve --project playground-app ng build --project flight-booking-lib
  4. @ManfredSteyer Publishing to npm Registry • Increment version in package.json

    • ng build --project flight-booking-lib • npm publish --registry http://localhost:4873 • npm install --registry http://localhost:4873
  5. @ManfredSteyer Alternatives for setting the Registry • Global: npm set

    registry http://localhost:4873 • Default: registry.npmjs.org • npm get registry • Project: .npmrc in project root
  6. @ManfredSteyer Disadvantages Distribution • Annoying within project • Prevents gritting

    further libs Versioning • Old versions • Conflicts • How to force devs to use latest version? Decoupling • What if lib authors == app authors?
  7. @ManfredSteyer Advantages Everyone uses the latest versions No version conflicts

    No burden with distributing libs Creating new libs: Adding folder Experience: Successfully used at Google, Facebook, …
  8. @ManfredSteyer Two Flavors • Like Workspaces/Solutions in different IDEs Project

    Monorepo • E. g. used at Google or Facebook Company-wide Monorepo
  9. @ManfredSteyer Advantages Sub Project Sub Project Sub Project Sub Project

    Sub Project Sub Project Sub Project Sub Project
  10. @ManfredSteyer Disadvantages Sub Project Sub Project Sub Project Sub Project

    Sub Project Sub Project Sub Project Sub Project Team A Team B Contract
  11. @ManfredSteyer Disadvantages More Coordination Blocking Tasks Complex Overall System One

    Architecture One Technology Stack Hard to change One size fits all?
  12. @ManfredSteyer µService Providing a (SPA based) Shell µApp µApp µApp

    Shell ✓ iframes ✓ Web Components ✓ Bootstrapping several SPAs
  13. @ManfredSteyer µService Providing a (SPA based) Shell µApp µApp µApp

    Shell ✓ iframes ✓ Web Components ✓ Bootstrapping several SPAs
  14. @ManfredSteyer MicroApp with Angular Elements @NgModule({ imports: [BrowserModule], declarations: [MicroAppComponent],

    bootstrap: [], entryComponents: [MicroAppComponent] }) export class AppModule { }
  15. @ManfredSteyer MicroApp with Angular Elements @NgModule({ imports: [BrowserModule], declarations: [MicroAppComponent],

    bootstrap: [], entryComponents: [MicroAppComponent] }) export class AppModule { }
  16. @ManfredSteyer MicroApp with Angular Elements @NgModule({ imports: [BrowserModule], declarations: [MicroAppComponent],

    bootstrap: [], entryComponents: [MicroAppComponent] }) export class AppModule { constructor(private injector: Injector) { } ngDoBootstrap() { } }
  17. @ManfredSteyer MicroApp with Angular Elements @NgModule({ imports: [BrowserModule], declarations: [MicroAppComponent],

    bootstrap: [], entryComponents: [MicroAppComponent] }) export class AppModule { constructor(private injector: Injector) { } ngDoBootstrap() { const MicroAppElement = createCustomElement( MicroAppComponent, { injector: this.injector }); customElements.define('micro-app', MicroAppElement); } }
  18. @ManfredSteyer Some General Advice for Macro-Architecture Shared state, navigation b/w

    apps Hyperlinks Legacy Apps or *very very* strong isolation? iframes Separate Deployment/ mix Technologies? Web Components Monolith w/ Libs and Monorepo little much yes no yes no Not a good fit for public web sites
  19. @ManfredSteyer Blog > SOFTWAREarchitekt.at • A Software Architect's Approach Towards

    Using Angular (And SPAs In General) For Microservices Aka Microfrontends • A Lightweight And Solid Approach Towards Micro Frontends (Micro Service Clients) With Angular And/Or Other Frameworks • Micro Apps With Web Components Using Angular Elements