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

Nachhaltige Client-Architekturen mit Angular El...

Nachhaltige Client-Architekturen mit Angular Elements

Heutzutage erhalten wir neue Web-Technologien und -Frameworks am laufenden Band. Framework-unabhängige Web Components und Micro Apps bieten Abhilfe für dieses Dilemma!
Angular Elements sind Custom Elements, welche in beliebige Web-Applikationen integriert werden können. Damit können wir wiederverwendbare Angular-Komponenten und -Widgets schreiben, welche in anderen Applikationen, unabhängig des Frameworks (z.B. React, Vue, Sharepoint), verwendet werden können. Zuerst werden wir uns mit den Grundlagen beschäftigen und betrachten danach den richtigen Einsatz von Polyfills, ShadowDOM und die Slot-API sowie Strategien zum effektiven Bundling mit Ivy.

Thomas Gassmann

September 13, 2019
Tweet

More Decks by Thomas Gassmann

Other Decks in Programming

Transcript

  1. Agenda • Intro Angular Elements • Web Components • Getting

    started with Angular Elements • Outlook
  2. «Angular is ideal for building complete applications, and our tooling,

    documentation and infrastructure are primarily aimed at this case.» Rob Wormald, Angular Team
  3. Platform Dependency Injection Decorators Zones Compile Binding Render Material Mobile

    Universal CLI Language Service Augury ngUpdate Router Animation i18n
  4. «[…] but it’s quite challenging to use in scenarios that

    don’t fit that specific Singe Page Application model.» Rob Wormald, Angular Team
  5. Use Cases • Enhancing existing HTML Pages • Content Management

    Systems integration • Use components in other environments or frameworks • Microfrontends • Migrating Legacy Apps
  6. Web Components Web Components are a set of features added

    by the W3C HTML Template Shadow DOM HTML Imports Custom Elements
  7. Custom Elements Custom elements share the same API surface as

    native DOM objects: • Attributes • Properties • Methods • Events
  8. Enter Angular Elements Provides a bridge from angular concepts to

    web components. @HostBinding() => Attributes @Input() => Properties @Output() => CustomEvents Lifecycle Hooks => Reactions
  9. Platform Dependency Injection Decorators Zones Compile Binding Render Material Mobile

    Universal CLI Language Service Augury ngUpdate Router Animation i18n
  10. • Create a new Angular CLI project ng new angularElements

    First Steps • Update Angular CLI • Add support for angular elements ng add @angular/elements • Generate new component ng g c <NAME> -v ShadowDom
  11. • Install NPM Package npm install @webcomponents/custom-elements –-save First Steps

    • Add import to polyfills.ts import '@webcomponents/custom-elements/custom -elements.min'; import '@webcomponents/custom-elements/src/native-shim';
  12. DI in Angular Elements Plattform Injector (Renderer) Module Injector (Services)

    Element Injector (ElementRef) Element Injector (ElementRef)
  13. Angular Elements in V8 • It is just the beginning

    • Size is too big for shipping in non Angular projects • Will be much better with Ivy (V9) • Will be much easier with V9+ • Browser Support.
  14. • Install package ngx-build-plus ng add ngx-build-plus Optimize and combine

    bundle • Add script command "build:element": "ng build --prod --output-hashing=none -- single-bundle --keep-polyfills" • Run Command npm run build:element
  15. Thomas Gassmann • Web development using .NET, Typescript and Angular

    • Trainer, Speaker @gassmannT thomasgassmann.net