<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: icyerasor</title>
    <description>The latest articles on DEV Community by icyerasor (@icyerasor).</description>
    <link>https://dev.to/icyerasor</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F313262%2F2c09e2c8-372b-482b-8639-305967013c38.png</url>
      <title>DEV Community: icyerasor</title>
      <link>https://dev.to/icyerasor</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/icyerasor"/>
    <language>en</language>
    <item>
      <title>Angular Elements - Modularized</title>
      <dc:creator>icyerasor</dc:creator>
      <pubDate>Thu, 06 Aug 2020 15:32:41 +0000</pubDate>
      <link>https://dev.to/icyerasor/angular-elements-modularized-3802</link>
      <guid>https://dev.to/icyerasor/angular-elements-modularized-3802</guid>
      <description>&lt;h3&gt;
  
  
  Angular-webcomp-elements?
&lt;/h3&gt;

&lt;p&gt;So you want to start using &lt;a href="https://www.webcomponents.org/"&gt;web components&lt;/a&gt;, mainly &lt;a href="https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements"&gt;custom elements&lt;/a&gt; with angular (10) == &lt;a href="https://angular.io/guide/elements"&gt;Angular Elements&lt;/a&gt;. If you don't, you might check out this &lt;a href="https://noti.st/naltatis/zQb2m5"&gt;video&lt;/a&gt; and &lt;a href="https://livebook.manning.com/book/micro-frontends-in-action/welcome/v-4/0"&gt;book&lt;/a&gt; by &lt;a href="https://twitter.com/naltatis"&gt;Michael Geers&lt;/a&gt;. There's a &lt;a href="https://blog.bitsrc.io/using-angular-elements-why-and-how-part-1-35f7fd4f0457"&gt;boatload&lt;/a&gt; of &lt;a href="https://medium.com/@jorgecasar/how-to-use-web-components-with-angular-41412f0bced8"&gt;tutorials&lt;/a&gt; out &lt;a href="https://dev.to/prestonjlamb/getting-started-with-angular-elements-3kj3"&gt;there&lt;/a&gt; explaining how to do this, &lt;a href="https://www.npmjs.com/package/@webcomponents/custom-elements"&gt;including&lt;/a&gt; still targeting ES5 as a compilation target (to support that still not completely dead IE5 👿).&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting started 👨‍💻
&lt;/h2&gt;

&lt;p&gt;The tutorials usually end with something like..&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;...and then you concatenate the outputs into a single file, include the resulting &lt;code&gt;awesome-element.js&lt;/code&gt; in an arbitrary index.html, use your custom -Tag et voilà: custom elements FTW 🎉.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You follow the steps to create a component &lt;strong&gt;within your existing project&lt;/strong&gt; and everything works.&lt;br&gt;
The next thing you might be wondering however is if that &lt;code&gt;awesome-element.js&lt;/code&gt; file really needs to be 8-10 MB(!), even though it just renders a simple button 😲:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;icyerasor:~$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;ng build
&lt;span class="gp"&gt;icyerasor:~$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt;.&lt;span class="o"&gt;{&lt;/span&gt;js,html&lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="nt"&gt;-alh&lt;/span&gt;
&lt;span class="go"&gt;total 33M
-rw-r--r-- 1 icyerasor 1049089 9,4M Aug  6 17:20 awesome-element.js
-rw-r--r-- 1 icyerasor 1049089  581 Aug  6 17:20 index.html
-rw-r--r-- 1 icyerasor 1049089 294K Aug  6 17:20 main.js
-rw-r--r-- 1 icyerasor 1049089 358K Aug  6 17:20 polyfills.js
-rw-r--r-- 1 icyerasor 1049089 664K Aug  6 17:20 polyfills-es5.js
-rw-r--r-- 1 icyerasor 1049089 6,2K Aug  6 17:20 runtime.js
-rw-r--r-- 1 icyerasor 1049089 715K Aug  6 17:20 styles.js
-rw-r--r-- 1 icyerasor 1049089 8,1M Aug  6 17:20 vendor.js
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Ivy, tree-shake 🍁 to the rescue?
&lt;/h2&gt;

&lt;p&gt;Okay, you remember that was just a dev-build. So you add &lt;em&gt;--prod&lt;/em&gt; and end up with maybe 1.5 MB (still way too much 😒) but kind of doable (for an internal PoC / first draft) working solution:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;icyerasor:~$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;ng build &lt;span class="nt"&gt;--prod&lt;/span&gt;
&lt;span class="gp"&gt;icyerasor:~$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt;.&lt;span class="o"&gt;{&lt;/span&gt;js,html&lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="nt"&gt;-alh&lt;/span&gt;
&lt;span class="go"&gt;total 3,4M
-rw-r--r-- 1 icyerasor 1049089 1,5M Aug  6 17:25 awesome-element.js
-rw-r--r-- 1 icyerasor 1049089  544 Aug  6 17:25 index.html
-rw-r--r-- 1 icyerasor 1049089 1,4M Aug  6 17:25 main.js
-rw-r--r-- 1 icyerasor 1049089 102K Aug  6 17:25 polyfills.js
-rw-r--r-- 1 icyerasor 1049089 160K Aug  6 17:25 polyfills-es5.js
-rw-r--r-- 1 icyerasor 1049089 1,5K Aug  6 17:25 runtime.js
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;At some point you need to really make that custom element production ready however. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A small side-note here: If you're not yet using Angular 9/10/+ and thus probably not the &lt;a href="https://angular.io/guide/ivy"&gt;Ivy&lt;/a&gt; compile / rendering pipeline - I highly recommend you to upgrade to it, as it greatly reduces build sizes by tree-shaking.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Why u no use them custom element everywhere 🤷?
&lt;/h2&gt;

&lt;p&gt;So you wonder how you could only put the really necessary parts of your application into that custom element. The solution I came up with for our project at &lt;a href="https://twitter.com/iteratec"&gt;iteratec&lt;/a&gt; is to move the parts of the custom element into an angular module. It works for me, but your mileage may vary.&lt;/p&gt;

&lt;p&gt;Another solution is obviously to define the awesome-element in a separate angular project and simply use it as a custom element (through the html tag) in your &lt;em&gt;main&lt;/em&gt; project (too). I didn't want to do this if possible, to reduce the number of projects and artifacts we have to deal with. Furthermore for my current project a custom element always has a &lt;strong&gt;&lt;em&gt;primary&lt;/em&gt;&lt;/strong&gt; application to which it belongs natively, while other applications use it sparely. Extracting the custom element into its own project and re-including it, probably also means you have the overhead of shared common libs not only in the &lt;em&gt;secondary&lt;/em&gt;/&lt;em&gt;consuming&lt;/em&gt; projects, but also in the &lt;em&gt;primary&lt;/em&gt; project. There are solutions to tackle this overhead by putting shared libs into the global scope, but this is an optimization I won't go into any further here.&lt;/p&gt;

&lt;h3&gt;
  
  
  Modules 📦 to the rescue?
&lt;/h3&gt;

&lt;p&gt;Without changing anything, your &lt;code&gt;awesome-element.js&lt;/code&gt; contains not only the parts needed for your custom element, but everything your application does.&lt;br&gt;
So my goal was to compile only the absolutely needed parts into an includable &lt;code&gt;awesome-element.js&lt;/code&gt; for the custom element.&lt;/p&gt;
&lt;h2&gt;
  
  
  The part you're here for 😌
&lt;/h2&gt;

&lt;p&gt;Steps to build the &lt;code&gt;awesome-element.js&lt;/code&gt; that contains only your custom element "module":&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You obviously need multiple modules. So not only &lt;code&gt;app.module.ts&lt;/code&gt; but another one that contains similar model configuration stuff, i.e. called &lt;code&gt;app-elements.module.ts&lt;/code&gt;. It should only include the dependencies needed for your custom element to do its work. It might look something like this:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;BrowserModule&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/platform-browser&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;CUSTOM_ELEMENTS_SCHEMA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Injector&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;NgModule&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;createCustomElement&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@angular/elements&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;AwesomeIconComponent&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./awesome-icon/awesome-icon.component&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;NgModule&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;schemas&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;CUSTOM_ELEMENTS_SCHEMA&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;declarations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nx"&gt;AwesomeIconComponent&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;imports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nx"&gt;BrowserModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
  &lt;span class="na"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;AwesomeIconComponent&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;AppElementsModule&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;injector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Injector&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;awesomeIconComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createCustomElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;AwesomeIconComponent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;injector&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="nx"&gt;customElements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;awesome-icon&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;awesomeIconComponent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;ngDoBootstrap&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Accordingly you'll need another &lt;code&gt;main.ts&lt;/code&gt; file, referencing the module. I.e. called &lt;code&gt;main-elements.ts&lt;/code&gt;. You import the specific module there and bootstrap it.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;enableProdMode&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;platformBrowserDynamic&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/platform-browser-dynamic&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;AppElementsModule&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./app/app-elements.module&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;environment&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./environments/environment&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;production&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;enableProdMode&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;platformBrowserDynamic&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bootstrapModule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;AppElementsModule&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;success&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Bootstrap success`&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Same for &lt;code&gt;tsconfig.app.json&lt;/code&gt; -&amp;gt; &lt;code&gt;tsconfig.app-elements.json&lt;/code&gt;. There you'll reference your &lt;code&gt;main-elements.ts&lt;/code&gt; file instead of the default &lt;code&gt;main.ts&lt;/code&gt;.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;extends&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./tsconfig.base.json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;compilerOptions&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;outDir&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./out-tsc/app&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;types&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;files&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/main-elements.ts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/polyfills.ts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;include&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/**/*.d.ts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Next, in your &lt;code&gt;angular.json&lt;/code&gt; file, you can extend the project -&amp;gt; architect -&amp;gt; build section by adding something like this:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;configurations&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;extension&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;main&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/main-elements.ts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;tsConfig&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;tsconfig.app-elements.json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;outputPath&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;../resources/public/elements&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;finally within your &lt;code&gt;package.json&lt;/code&gt; you add a new script
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;build:elements&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ng build &amp;amp;&amp;amp; ng build --output-hashing none --configuration elements &amp;amp;&amp;amp; node concatenate.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Calling &lt;code&gt;npm run build:elements-prod&lt;/code&gt; will build the regular app (incudling your custom element), and then build the app again, but this time use the &lt;code&gt;elements&lt;/code&gt; configuration, that outputs its results to a different location. By using the &lt;code&gt;elements&lt;/code&gt; configuration the build references the following: &lt;code&gt;tsconfig.app-elements.json&lt;/code&gt; -&amp;gt; &lt;code&gt;main-elements.ts&lt;/code&gt; -&amp;gt; &lt;code&gt;app-elements.module.ts&lt;/code&gt; and thus only your desired module. Finally the files are joined into a single one through the concatenate call.&lt;/p&gt;

&lt;p&gt;The concatenate.js being something along the lines of..:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fs-extra&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;concat&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;concat&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;build&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;files&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../resources/public/elements/vendor.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../resources/public/elements/polyfills-es5.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../resources/public/elements/polyfills.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../resources/public/elements/runtime.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../resources/public/elements/main.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;];&lt;/span&gt;

  &lt;span class="c1"&gt;// vendor.js is not present in --prod builds&lt;/span&gt;
  &lt;span class="nx"&gt;files&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;files&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pathExistsSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ensureDir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../resources/public/elements&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;files&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../resources/public/elements/awesome-element.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="p"&gt;})();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The results for me with this approach are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;icyerasor:~$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;npm run build:elements-prod
&lt;span class="gp"&gt;icyerasor:~$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt;.&lt;span class="o"&gt;{&lt;/span&gt;js,html&lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="nt"&gt;-alh&lt;/span&gt;
&lt;span class="go"&gt;total 985K
-rw-r--r-- 1 icyerasor 1049089 395K Aug  7 09:02 awesome-element.js
-rw-r--r-- 1 icyerasor 1049089  544 Aug  7 09:02 index.html
-rw-r--r-- 1 icyerasor 1049089 132K Aug  7 09:02 main.js
-rw-r--r-- 1 icyerasor 1049089 102K Aug  7 09:02 polyfills.js
-rw-r--r-- 1 icyerasor 1049089 160K Aug  7 09:02 polyfills-es5.js
-rw-r--r-- 1 icyerasor 1049089 1,5K Aug  7 09:02 runtime.js
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;395kB might be still a lot for a single custom element that basically does nothing, but is a great improvement down from 1.5MB.&lt;/p&gt;

&lt;h3&gt;
  
  
  Improvements 🔭
&lt;/h3&gt;

&lt;p&gt;Haven't looked into those in detail yet, but probably will in the next weeks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Put the custom element in an angular &lt;a href="https://angular.io/guide/creating-libraries"&gt;library&lt;/a&gt;?&lt;/li&gt;
&lt;li&gt;Use &lt;a href="https://github.com/manfredsteyer/ngx-build-plus#readme"&gt;ngx-build-plus&lt;/a&gt; which greatly simplyfies configuring Angular elements (polyfills, single-bundle concatenation).&lt;/li&gt;
&lt;li&gt;as noted above: putting shared libs into the global scope would greatly improve the awesome-element.js size&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>iteratec cooperative wanted poster founding member - nurDemTeam eG Steckbrief Gründungsmitglied</title>
      <dc:creator>icyerasor</dc:creator>
      <pubDate>Mon, 03 Aug 2020 20:27:50 +0000</pubDate>
      <link>https://dev.to/icyerasor/iteratec-nurdemteam-eg-steckbrief-grundungsmitglied-4cpg</link>
      <guid>https://dev.to/icyerasor/iteratec-nurdemteam-eg-steckbrief-grundungsmitglied-4cpg</guid>
      <description>&lt;p&gt;So our &lt;a href="https://www.iteratec.com"&gt;company&lt;/a&gt; is in transition to becoming a cooperative (Genossenschaft) - which means it will soon be legally owned 100% by a part of it's employees: the associates (Genossen). Right now its 49% to 51% founders. Basically nothing is gonna change - which is a good thing as we are already driving most of the companies decisions from the "bottom" up.&lt;/p&gt;

&lt;p&gt;Anyway, one of the things we wanted to do is to document the process of establishing this cooperative (with all those rules in Germany it's a loot of hoops you have to jump through) and that's why we asked our employees to answer some questions, similar to an autograph book or wanted poster.&lt;/p&gt;

&lt;p&gt;I decided it was finally time to write that first DEV.to post almost 6 months ago - so with half a year delay.. let's kill two birds with one stone.&lt;/p&gt;

&lt;p&gt;The following is in german - future posts will stick to english and probably use fewer emojis, I promise 🤞.&lt;/p&gt;

&lt;h2&gt;
  
  
  Was war dein erster Computer?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--G-aAgLYm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/h15c65w261n0vlhs1h55.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--G-aAgLYm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/h15c65w261n0vlhs1h55.JPG" alt="drawing" width="400"&gt;&lt;/a&gt;&lt;/p&gt;
VTech Genius Leader 4000 Quadro



&lt;p&gt;War eigentlich kein richtiger Computer 🖥️, sondern zunächst mal ein Gameboy 🎮. Kurz danach folgte dann etwas sinnvolleres: Ein &lt;strong&gt;VTech &lt;em&gt;Genius&lt;/em&gt; Leader 4000 &lt;em&gt;Quadro&lt;/em&gt;&lt;/strong&gt; 🤓! &lt;br&gt;
Neben einigen vorgefertigten textuellen multiple Choice- und mathematischen Lernprogrammen gab es auch einen &lt;strong&gt;BASIC&lt;/strong&gt;-Interpreter 👨‍💻 und eine wirklich ganz brauchbare Anleitung als kleines physikalisches Handbuch 😍.. &lt;/p&gt;

&lt;h2&gt;
  
  
  Warum bist du dann Software Engineer geworden?
&lt;/h2&gt;

&lt;p&gt;Weil das Programmieren von "Guess the number" ❓ und kleinen Text-Adventures 🗡️ mich irgendwie gepackt hat und ich mich seitdem für Technik 💽 begeistere. Einen wesentlichen Grundstein legte dann aber auch ein Lehrer 👨‍🏫 in der Realschule, der mir sehr bildhaft von seinem Neffen erzählte, der anspruchsvolle Administrationstätigkeiten bei systemrelevanten, kritischen IT-Anwendungen durchführte. Er war dadurch zwar oft in Bereitschaft 😓, aber auch sehr gefragt, beliebt und nicht zuletzt gut bezahlt 💸. Danke für diese Inspiration Herr Helmut Knittel 🙏!&lt;/p&gt;

&lt;h2&gt;
  
  
  Was ist das Beste an der Arbeit als ITler?
&lt;/h2&gt;

&lt;p&gt;In einem tollen Team 🎉 - und trotzdem autonom - innovative Anwendungen erschaffen zu können, welche die Bedürfnisse der Nutzer befriedigen und damit einen sinnvollen Beitrag 💝 zu leisten. Und dabei auch noch stetig etwas neues zu lernen 💡. Die begehrten Kriterien 🟦 Autonomy, Purpose, &amp;amp; Mastery bzw. die mir eigentlich sogar noch liebere Alternative "Social Meaningful Contribution" trifft das dann meist ganz gut ☑️.&lt;/p&gt;

&lt;h2&gt;
  
  
  Was wärst du, gäbe es keine IT?
&lt;/h2&gt;

&lt;p&gt;Schmied ☭ (Nicht wirklich, passt nur zu meinem Nachnamen), oder etwas ähnliches 👨‍🌾 auf den elterlichen Feldern (anderer Nachnamensteil) 🌾 in Berchtesgaden 🏔️.&lt;/p&gt;

&lt;h2&gt;
  
  
  Warum iteratec, was hat dich hierhergeführt?
&lt;/h2&gt;

&lt;p&gt;Ich kam für eine Diplomarbeit 🎓. Ich blieb weil ich mich wohl nicht zu schlecht angestellt hatte und vor allem wegen der netten Kolleg:innen 👪 und der tollen Atmosphäre 🏢.&lt;/p&gt;

&lt;h2&gt;
  
  
  Warum bist du Mitglied der #nurdemteam Genossenschaft geworden?
&lt;/h2&gt;

&lt;p&gt;Weil ich auch weiterhin aktiv Einfluss ⚙️ darauf nehmen möchte, mit &lt;em&gt;&lt;em&gt;wem&lt;/em&gt;&lt;/em&gt;, &lt;em&gt;&lt;em&gt;wie&lt;/em&gt;&lt;/em&gt; und &lt;em&gt;&lt;em&gt;woran&lt;/em&gt;&lt;/em&gt; wir als Firma in Zukunft 🔮 arbeiten werden.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wie siehst Du die Zukunft der eG? Wage einen Ausblick in die nächsten 5-10 Jahre
&lt;/h2&gt;

&lt;p&gt;Es wird sicherlich eine turbulente 🌪️ und anstrengende 🥵 Zeit. Ich denke aber, dass dieses Modell in Zukunft noch viel landläufiger 📈 in Erscheinung treten wird und wir daher in 5-10 Jahren mal wieder sagen können: &lt;em&gt;"Machen wir schon seit 10 Jahren so"&lt;/em&gt;. Also in etwa so wie mit diesen &lt;strong&gt;itera&lt;/strong&gt;tiven, inkrementellen Vorgehensmodellen von heute schon damals.. 😂&lt;/p&gt;

&lt;h2&gt;
  
  
  Der bislang beste Moment bei iteratec
&lt;/h2&gt;

&lt;p&gt;Igluparty ☃️ im Kühtai. Ja liebe Kolleg:innen, es existieren Fotoaufnahmen 📸. Keine Angst, sie bleiben intern 🤐.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mein Lebens-/Arbeitsmotto
&lt;/h2&gt;

&lt;p&gt;TBD.&lt;/p&gt;

&lt;h2&gt;
  
  
  Diese Wörter beschreiben mich am besten
&lt;/h2&gt;

&lt;p&gt;Empathischer &amp;amp; ungeduldiger &amp;amp; perfektionistischer Prokrastinator 🤪.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ich kann nicht leben ohne
&lt;/h2&gt;

&lt;p&gt;Meinen Balkon mit Westblick und daher täglich wechselnder Sonnenuntergangs-Stimmung 🌇.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ich würde nie wieder
&lt;/h2&gt;

&lt;p&gt;Mich für undefinierte und nicht abzugrenzende Aufgaben zuständig fühlen, ohne zu wissen was von mir erwartet wird 😠.&lt;/p&gt;

&lt;h2&gt;
  
  
  iteratec Facts
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Frage&lt;/th&gt;
&lt;th&gt;Antwort&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Bei iteratec seit&lt;/td&gt;
&lt;td&gt;2008&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Standort&lt;/td&gt;
&lt;td&gt;München&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Schwerpunkt&lt;/td&gt;
&lt;td&gt;JOATMON&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Bild
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yvz9LJR3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kalf3d0pspcb9uu1k6s8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yvz9LJR3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kalf3d0pspcb9uu1k6s8.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>newwork</category>
      <category>cooperative</category>
      <category>leadership</category>
      <category>business</category>
    </item>
  </channel>
</rss>
