<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by cory lewis on Medium]]></title>
        <description><![CDATA[Stories by cory lewis on Medium]]></description>
        <link>https://medium.com/@cory.lewis1997?source=rss-b5eed2fd26e4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*A2pL-VZSj6WOHYMZVefa7A.jpeg</url>
            <title>Stories by cory lewis on Medium</title>
            <link>https://medium.com/@cory.lewis1997?source=rss-b5eed2fd26e4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 16:32:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cory.lewis1997/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Angular 17 Component Library wired for Web Components!]]></title>
            <link>https://medium.com/@cory.lewis1997/angular-17-component-library-wired-for-web-components-3dccb87a6f87?source=rss-b5eed2fd26e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/3dccb87a6f87</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[angular-cli]]></category>
            <category><![CDATA[storybook]]></category>
            <dc:creator><![CDATA[cory lewis]]></dc:creator>
            <pubDate>Mon, 18 Dec 2023 16:17:45 GMT</pubDate>
            <atom:updated>2023-12-18T16:17:45.305Z</atom:updated>
            <content:encoded><![CDATA[<p>I found that there are quite a few of resources out on the web for creating an Angular library but not so much up to date walkthroughs explaining how to take your Angular CLI generated library and export one or many of its components out as framework agnostic web component(s).</p><blockquote>In this article, we will create two libraries: a pure Angular library and a web component library. The web component library will wrap around the Angular library and use web component hooks to expose the components as native HTML elements.</blockquote><h3>Important!</h3><p>This is my current projects environment versions for your reference while stepping through this tutorial</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*XaHyRWqPDSCY_q3W7YB2mQ.png" /><figcaption>ng version</figcaption></figure><h3>Getting Started</h3><p>The first step of this tutorial is to install the Angular CLI globally, which will allow us to use the “ng” commands in the terminal. Then, we will create our initial project using the “ng new” command. In this tutorial, we will work with two libraries: a pure Angular 17 library (“my-library”) and a web component library (“my-library-web-components”). The web component library will be framework agnostic and will include the web component and the Angular runtime. If you only want to use the web component library, you can skip publishing the Angular 17 library to npm.</p><pre># Install the latest Angular CLI globally<br>npm i -g @angular/cli<br><br># Generate the Angular workspace<br>ng new my-workspace --no-create-application<br><br># Create your library<br>ng generate library my-library<br><br># Create your Web Component Library<br>ng generate application my-library-web-components</pre><h4>Add Storybook (optional)</h4><p>Storybook is a tool that enables developers to create scenarios and playgrounds for their components. It also provides a beautiful interface for collaboration and component reusability among large teams. For a library like this, publishing a playground for your consumers to explore would be a nice feature.</p><pre>npx storybook@latest init</pre><blockquote>Important: To scaffold both Angular projects/libraries, you will need to run the storybook init command twice. Each time, you will be prompted to select a project to scaffold. Please choose a different project for each run.</blockquote><h4>Add Prettier <em>(optional)</em></h4><p>By formatting the code according to your specified schema, Prettier will help you maintain a consistent coding style throughout the code base. The package we are going to install will also add a husky pre-commit hook to the angular project, ensuring that your coding standards are met before each commit.</p><pre># Run this command in your terminal and follow prompts<br>ng add @schuchard/prettier<br><br># Run prettier<br>npm run prettier</pre><blockquote>More about the @schuchard/prettier package can be found <a href="https://github.com/schuchard/prettier-schematic?tab=readme-ov-file#angular-prettier-schematic">here</a></blockquote><h4>Add Linting (optional)</h4><p>We will want to install the eslint schematic to gain access to its toolchain for linting our libraries</p><pre># Run this command to add the schematic<br>ng add @angular-eslint/schematics<br><br># Add lint configuration for my-library<br>ng g @angular-eslint/schematics:add-eslint-to-project my-library<br><br># Add lint configuration for my-library-web-components<br>ng g @angular-eslint/schematics:add-eslint-to-project my-library-web-components</pre><blockquote>See <a href="https://github.com/angular-eslint/angular-eslint">this</a> github repository for additional information about the schematic and its toolchain</blockquote><h4>Building “my-library”</h4><pre>ng build my-library --configuration production</pre><blockquote>You should see a dist folder generated at the root of your application with a folder inside called “my-library”. Success your library is now building!</blockquote><h4>Building ”my-library-web-components”</h4><p>Now at this point our angular library is building correctly but our templated build process for “my-library-web-components” has some work to be done in order to get things working cleanly.</p><p>To start let’s see how it currently builds first.</p><pre># Build the library to see its current output<br>ng build my-library-web-components --configuration production</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8--kjB0pj3BSOpCFoYm33Q.png" /></figure><p>You may notice that each file has a build hash appended to its name. This is normal for a traditional application build, but not for our use case. We want to have predictable file names for our package.json entrypoint. Therefore, we need to disable “outputHashing” in the build configuration for my-library-web-components inside angular.json.</p><p><em>Delete the highlighted line below from angular.json my-library-web-components.build</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*jUQDaWUJkm84BgfQ_eb32g.png" /></figure><p>Let’s build again and see if that changed anything</p><pre>ng build my-library-web-components --configuration production</pre><p>Your build output should look similar to this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*kP-5ph3KHGKhmUs3X-dG2Q.png" /></figure><blockquote>Excellent! By disabling “outputHashing”, we have ensured that the file names remain the same for every build.</blockquote><p>Next we need to create a package.json in the root of my-library-web-components</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U4OBJO48YhxL6WONALMWlw.png" /></figure><p>And inside the package.json we will define the following:</p><pre>{<br>  &quot;name&quot;: &quot;my-library-web-components&quot;,<br>  &quot;version&quot;: &quot;0.0.1&quot;,<br>  &quot;main&quot;: &quot;bundle.js&quot;<br>}</pre><blockquote>This is very rudimentary but a good starting point for a basic package.json needed to publish to npm</blockquote><h4>Setup web component bootstrapping</h4><p>The ng generate command created some basic files in the projects/my-library-web-components/src/app/* directory. However, we only need the app.config.ts file. Move this file up a directory and rename it to main.config.ts. It should be next to your main.ts file. You can delete the rest of the files in the app/* directory.</p><p>Your src directory should look like this when you are done:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*CQS54OoHZmTFz2NJ4QCTlQ.png" /></figure><p>Replace ALL content inside <strong>main.config.ts</strong> with:</p><pre>import { ApplicationConfig } from &#39;@angular/core&#39;;<br><br>export const appConfig: ApplicationConfig = {<br>    providers: [],<br>};</pre><p>Replace ALL content inside <strong>main.ts</strong> with:</p><pre>import {createApplication} from &#39;@angular/platform-browser&#39;;<br>import {appConfig} from &#39;./main.config&#39;;<br>import {createCustomElement} from &#39;@angular/elements&#39;;<br>import { MyLibraryComponent } from &#39;my-library&#39;;<br>import { ApplicationRef } from &#39;@angular/core&#39;;<br><br>(async () =&gt; {<br>  const app: ApplicationRef = await createApplication(appConfig);<br><br>  // Define Web Components<br>  const myLibraryComponent = createCustomElement(MyLibraryComponent, {injector: app.injector});<br>  customElements.define(&#39;my-library-component&#39;, myLibraryComponent);<br>})();</pre><p>Modify your <strong>index.html</strong> to use your web component like:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>    &lt;head&gt;<br>        &lt;meta charset=&quot;utf-8&quot; /&gt;<br>        &lt;title&gt;EtlpWc&lt;/title&gt;<br>        &lt;base href=&quot;/&quot; /&gt;<br>        &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot; /&gt;<br>    &lt;/head&gt;<br>    &lt;body&gt;<br>        &lt;my-library-component&gt;&lt;/my-library-component&gt;<br>    &lt;/body&gt;<br>&lt;/html&gt;</pre><blockquote>This is the index.html located in the same directory as your main.ts and main.config.ts</blockquote><h4>Smoke Test the web component</h4><p>We will want to first build the my-library project and afterwards build my-library-web-components because there is a dependency between them.</p><pre>ng build my-library -c production<br>ng build my-library-web-components -c production</pre><p>Now that everything is built we want to test that it works</p><pre># To view our distribution build we will need to use a tool like http-server.<br># install globally with:<br>npm i http-server -g<br><br># Start the server<br>http-server ./dist/etlp-wc/browser</pre><p>View your app at <a href="http://127.0.0.1:8091/index.html">http://127.0.0.1:&lt;YOUR_PORT&gt;/index.html</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1v57YMFrcVpvJ875gg34Cg.png" /><figcaption>your index.html loading successfully</figcaption></figure><h4>Create importable bundle file</h4><p>We have made good progress so far, but we still have one major issue to resolve. If you look at the dist/my-library-web-components/browser/index.html file, you will see that it loads two files: polyfills.js and main.js, using the &lt;script&gt; tag. However, we want to create a library with only one entry point in our package.json file, not two. To fix this, we will generate a third file called bundle.js.</p><p>All we need to do is open our angular.json at the root of our project and add a script at path my-library-web-components.architect.build.options.scripts<em>.</em></p><p>Add this scripts array to your scripts build options:</p><pre><br>&quot;scripts&quot;: [<br>    {<br>        &quot;input&quot;: &quot;./scripts/postbuild-bundler.js&quot;,<br>        &quot;bundleName&quot;: &quot;bundle&quot;,<br>        &quot;inject&quot;: false<br>    }<br>]</pre><p>Now at the root of our project lets create scripts directory with postbuild-bundler.js inside with content:</p><pre>async function loadModules() {<br>    // Import the polyfills and main modules and wait for them to finish<br>    await import(&#39;./polyfills.js&#39;);<br>    await import(&#39;./main.js&#39;);<br><br>    // Do any extra stuff you need for init here.<br>  }<br><br>  loadModules();</pre><blockquote>This file will serve as the bundle module loader for the web components library</blockquote><p>Verify everything is setup correctly by building my-library-web-components. ng build my-library-web-components -c production . You should see a hierarchy like this in your web component library distribution folder:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/265/1*tPDw81NcNOAib1p-kN_tiA.png" /></figure><h3>Last Step</h3><p>In order to publish you will need to change directory into your distribution folder and publish. Below is an example:</p><pre># Publish your library<br>cd dist/my-library<br>npm version 1.0.0<br>npm publish<br><br># Publish your web component library<br>cd dist/my-library-web-components/browser<br>npm version 1.0.0<br>npm publish</pre><p>And that’s it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3dccb87a6f87" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OpenSSL in C++]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">One of the most powerful and opaque libraries for server side c++ is the openssl library. It has many useful tools built into it but fails&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@cory.lewis1997/openssl-in-c-ad8860d097ae?source=rss-b5eed2fd26e4------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@cory.lewis1997/openssl-in-c-ad8860d097ae?source=rss-b5eed2fd26e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad8860d097ae</guid>
            <category><![CDATA[helpful-tips]]></category>
            <category><![CDATA[openssl]]></category>
            <category><![CDATA[cplusplus]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[rsa]]></category>
            <dc:creator><![CDATA[cory lewis]]></dc:creator>
            <pubDate>Tue, 25 Aug 2020 22:17:27 GMT</pubDate>
            <atom:updated>2020-08-25T22:17:27.973Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
        </item>
    </channel>
</rss>