<?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 Kristofer Joseph on Medium]]></title>
        <description><![CDATA[Stories by Kristofer Joseph on Medium]]></description>
        <link>https://medium.com/@dam?source=rss-45a43bb4f2fb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*h0NZmJcU20dim_zvZahVJg.jpeg</url>
            <title>Stories by Kristofer Joseph on Medium</title>
            <link>https://medium.com/@dam?source=rss-45a43bb4f2fb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 22:47:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dam/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[Serverless ES Modules]]></title>
            <link>https://medium.com/let-s-begin/serverless-es-modules-1e9bd5e15086?source=rss-45a43bb4f2fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e9bd5e15086</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[frontend]]></category>
            <dc:creator><![CDATA[Kristofer Joseph]]></dc:creator>
            <pubDate>Tue, 13 Nov 2018 21:56:04 GMT</pubDate>
            <atom:updated>2019-01-14T06:56:01.585Z</atom:updated>
            <content:encoded><![CDATA[<h4>Frontend patterns with <a href="https://www.npmjs.com/package/@architect/architect">Architect serverless framework</a></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DBXJJ4hsLHVZwxsB2xUEfQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/pbns0n5xt1o?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Johny Goerend</a></figcaption></figure><p>The vast majority of <a href="https://caniuse.com/#feat=es6-module">browsers in use today support ES Modules</a>, but until recently it’s been difficult to use modules in your project. Before widespread browser support, modules required a compilation step via a tool like Webpack (or Browserify, or Gulp, etc.) in order to convert them into something the browser could use.</p><p>But now you can use ES Modules in the browser without any extra overhead, making them the perfect companion to the serverless stack.</p><h3>Architect enables you to serve ES Modules to the browser via local workflows and from Lambda cloud functions.</h3><p>This post will walk you through how to get started working with standards based JavaScript modules in an Architect serverless project.</p><blockquote><em>We’ll build on concepts from </em><a href="https://blog.begin.com/serverless-front-end-patterns-with-architect-views-cf4748aa1ec7"><em>serverless frontend patterns with Architect Views</em></a><em>, so you may find it helpful to </em><a href="https://blog.begin.com/serverless-front-end-patterns-with-architect-views-cf4748aa1ec7"><em>check that out first</em></a><em>.</em></blockquote><h4>1. Make a new Architect project</h4><pre>mkdir arc-esm<br>cd arc-esm<br>npm init --yes<br>npm i @architect/architect</pre><p>Then create a .arc file in the root of your project:</p><pre>@app<br>arc-esm</pre><pre>@http<br>get /js/:module</pre><blockquote><em>get /js/:module is an example of a parameterized route. Hitting the url </em><em>/js/mycode.mjs will pass </em><em>mycode.mjs as </em><em>req.params.module to your Lambda function handler.</em></blockquote><p>Next, generate your app locally:</p><pre>npx create --local<br>mkdir src/shared<br>mkdir src/views</pre><p>Here’s what Architect project will look like on your local filesystem:</p><pre>arc-esm<br>├── public/<br>├── src<br>│   ├── http<br>│   │   └── get-js-000module/<br>│   ├── shared/<br>│   └── views/<br>└── .arc</pre><h4>2. Add your index page to src/public</h4><p>Create src/public/index.html</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;Architect ES Modules&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>  &lt;h1&gt;Architect&lt;/h1&gt;<br>  &lt;div id=&quot;js-message&quot;&gt;&lt;/div&gt;<br>  &lt;!-- ES MODULE 👇🏾 --&gt;<br>  &lt;script type=&quot;module&quot; src=&quot;/js/main.mjs&quot; crossorigin&gt;&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><h4>3. Add a view module</h4><p>Create src/views/hello.mjs</p><pre>export default function Hello () {<br>  console.log(&#39;Why, hello there.&#39;)<br>  let message = document.getElementById(&#39;js-message&#39;)<br>  message.innerHTML = &#39;You are now rocking with ES Modules.&#39;<br>}</pre><blockquote><em>Tip: code in </em><em>src/views is automatically shared to </em><em>HTTP GET routes</em></blockquote><h4>4. Add a main entry point script</h4><p>Create src/views/main.mjs</p><pre>import Hello from &#39;./hello.mjs&#39;<br>Hello()</pre><blockquote><em>Tip: having a main ES Module that imports all the scripts needed for a page allows you to load the rest of your modules in parallel. Modules are also cached in the browser so subsequent requests for the same module will not impact app performance.</em></blockquote><h4>4. Edit your Lambda function to return requested modules</h4><p>Update src/http/get-js-000module/index.js</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/98e9b5eebefc19b0fc9a1aff577a2460/href">https://medium.com/media/98e9b5eebefc19b0fc9a1aff577a2460/href</a></iframe><blockquote><em>Notice the response </em><em>Content-Type of </em><em>text/javascript, which is required by the browser to load ES Modules</em></blockquote><h4>5. Test it out in your local Architect sandbox</h4><p>npx sandbox</p><p>You should see console output showing you that your module route has been mounted, as well as the local URL:</p><pre>get /js/:module ....................... get-js-000module</pre><pre>Started HTTP &quot;server&quot; @  <a href="http://localhost:3333/">http://localhost:3333</a></pre><blockquote><em>Alternatively, you can also add </em><em>&quot;start&quot;: &quot;npx sandbox&quot; to your </em><em>package.json scripts and run your local sandbox server with </em><em>npm start</em></blockquote><h4>That’s it! 🌈</h4><p>Load up http://localhost:3333/js/main.js via Architect’s seamless local development environment, and now you’re serving ES Modules without ever having to set up a bundler, or write build scripts. ✨</p><blockquote>→ <a href="https://github.com/arc-repos/arc-example-es-modules">View the complete example project on GitHub</a></blockquote><p>@dam💕</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e9bd5e15086" width="1" height="1" alt=""><hr><p><a href="https://medium.com/let-s-begin/serverless-es-modules-1e9bd5e15086">Serverless ES Modules</a> was originally published in <a href="https://medium.com/let-s-begin">Beginners’ Guide</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serverless front-end patterns with Architect Views]]></title>
            <link>https://medium.com/let-s-begin/serverless-front-end-patterns-with-architect-views-cf4748aa1ec7?source=rss-45a43bb4f2fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf4748aa1ec7</guid>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Kristofer Joseph]]></dc:creator>
            <pubDate>Mon, 29 Oct 2018 13:01:01 GMT</pubDate>
            <atom:updated>2019-01-14T06:54:46.043Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hfPZ6di1ZaWEG__Q-i0VFQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/E300UYYFlLo?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Val Vesa</a></figcaption></figure><h3>Serverless frontend patterns with Architect Views</h3><p><a href="https://arc.codes/">Architect</a> projects can now use the src/views directory, which automatically shares code to all — or just some — of your project’s @http GET functions.</p><p>This might seem like a small change, but it opens the door for a multitude of common frontend patterns, such as sharing view components for the server side render of PWAs.</p><h4>Try it out</h4><p>Create a new Architect project:</p><pre>mkdir arc-views<br>cd arc-views<br>npm init --yes<br>npm i @architect/architect</pre><p>Create this .arc file in the root of your project:</p><pre>@app<br>arc-views</pre><pre>@http<br>get /</pre><p>Generate your demo app locally:</p><pre>npx create --local<br>mkdir src/views<br>mkdir src/shared</pre><p>Here’s what your Architect project will look like:</p><pre>arc-views<br>├── public/<br>├── src<br>│   ├── http<br>│   │   └── get-index/<br>│   ├── shared/<br>│   └── views/<br>└── .arc</pre><p>Now let’s add a view. Create src/views/layout.js:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/058d52c302c7ab610c084bdd216db6ca/href">https://medium.com/media/058d52c302c7ab610c084bdd216db6ca/href</a></iframe><p>Your new layout.js will be copied to src/http/get-index/node_modules/@architect/views/layout.js</p><p>Here’s how to require it in your Lambda: let Layout = require(&#39;@architect/views/layout&#39;)</p><p>Update src/http/get-index/index.js to use your new layout:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb8dfbdd4928e18797a948dc47aea47c/href">https://medium.com/media/cb8dfbdd4928e18797a948dc47aea47c/href</a></iframe><blockquote><em>Bonus points if you added your own heading to the layout with:</em></blockquote><blockquote><em>body: Layout({heading: &#39;MY AWESOME HEADING!&#39;})</em></blockquote><p>Now start your local Architect sandbox server:</p><pre>npx sandbox</pre><p>Follow the terminal output and navigate to <a href="http://localhost:3333/">http://localhost:3333</a> to view your work.</p><p>That’s it! A few commands, two files, and you’re up and running with Architect Views.</p><h4>The @views pragma</h4><p>By default, src/views gets copied to the node_modules directory of every @http GET function, because those are the functions most likely to return HTML.</p><blockquote>But what if you don’t want to share views to all http get routes?</blockquote><p>That’s what the @views pragma in your .arc file is for.</p><p>Update your .arc file to this:</p><pre>@app<br>arc-views</pre><pre>@http<br>get /<br>get /about<br>get /css/:stylesheet</pre><pre>@views<br>get /<br>get /about</pre><p>Run create to generate the new Lambda function stubs:</p><pre>npx create --local<br>mkdir src/views</pre><p>Now when you run your sandbox server your views will only be copied to node_modules/@architect/views in your get-index and get-about functions, leaving your get-css-000stylesheet function as is.</p><h4>In conclusion</h4><p>Architect views helps you share view specific code between Lambda functions. We can’t wait to see what you build!</p><blockquote>→ <a href="https://github.com/arc-repos/arc-examples-views"><em>View the complete example project on GitHub</em></a></blockquote><p>@dam 💕</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf4748aa1ec7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/let-s-begin/serverless-front-end-patterns-with-architect-views-cf4748aa1ec7">Serverless front-end patterns with Architect Views</a> was originally published in <a href="https://medium.com/let-s-begin">Beginners’ Guide</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>