<?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 Sindre Øye Svendby  on Medium]]></title>
        <description><![CDATA[Stories by Sindre Øye Svendby  on Medium]]></description>
        <link>https://medium.com/@sinsvend?source=rss-7f145f74215d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*bhyKlejvJ5VvWSPO.jpg</url>
            <title>Stories by Sindre Øye Svendby  on Medium</title>
            <link>https://medium.com/@sinsvend?source=rss-7f145f74215d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 15:03:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sinsvend/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[Module bundling — can we do it better ?]]></title>
            <link>https://medium.com/@sinsvend/module-bundling-can-we-do-it-better-f8c563851400?source=rss-7f145f74215d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8c563851400</guid>
            <category><![CDATA[parcel-js]]></category>
            <category><![CDATA[es6-module]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[cloudflare]]></category>
            <dc:creator><![CDATA[Sindre Øye Svendby ]]></dc:creator>
            <pubDate>Mon, 25 Dec 2017 23:57:17 GMT</pubDate>
            <atom:updated>2017-12-26T00:22:13.909Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fL9d6F7Vk69UzDi98Sd7DA.jpeg" /></figure><p>Not that long ago <a href="https://github.com/parcel-bundler/parcel">Parcel</a> where introduced to the web community, and there where a lot of excitement about it.</p><p>Some of the benefits it promised was that it was fast and zero configuration. and it started the bundling from a HTML file.</p><p>Some years ago when webpack was introduced it started parsing module that imported other assets, and its been a thrill, today we expect a lot of our bundling tools.</p><p>My observation is that people (and me) think webpack is quite complicated, because it gives you so much power. I think part of it is because we want to spend time working on what the application do, not how it is served (best) to the user.</p><p>The last decade we have seen this happen on our operations. From being used to have to setup a server including hardware, we went trough IaaS, and now we now have <a href="https://www.heroku.com/">Heroku</a>, <a href="http://gatsbyjs.org/">Gatsby</a>, <a href="https://zeit.co/now">Now</a> or you can use <a href="https://cloud.google.com/functions/">FaaS</a>. All of these approaches is trying to reduce time we are spending on technical stuff, and not the business.</p><p>Also in the front of the application we see that there are SaaS products focusing on speed and caching. <a href="http://cloudflare.com/">Cloudflare</a> is maybe the biggest player in that field.</p><p>Could we do something similar for transpiling and bundling? Lets go back to Parcel for a moment. I really liked that parcel started from a HTML file. After thinking on this, I realized that we should separate _what_ we are doing (the application), whit _how_ it’s served.</p><p>So parcel takes and HTML file as input, I think this is a good starting point for parcel. But what if we did this runtime? It sound like a bad idea, but bear with me.</p><p>What if used parcel as an express middleware (just an example), and just run parcel on the representation of the HTML file, then we could for instance only serve the transpiled code that is needed on a per browser/useragent basis. ?</p><p>What if stop think about express and parcel, and image that cloudflare or a SaaS provider in front of our application, took the responds, and transpiled it if needed, and split it up to chunks as needed.</p><p>By doing this runtime, and putting this on a SaaS provider (or trough a OSS project). I think it should be possible to a lot:</p><p>What if the chunking strategy was updated runtime based on the user performance?</p><p>What if the one chunk was split up to several smaller chunks and saved in localstorage, and you would only receive the parts you needed, without having to pay the price upfront in the main js file, or put the small piece in each JS file?</p><p>What if we only delivered the CSS prefix needed for the browser in question (Facebook already does this)</p><p>What if unused code was detected and skipped?</p><p>What if all websites that used react, jquery, moment or another popular lib could share the cached version of these libs? or at least all the customers from the platform that delived this service (e.g heroku or cloudflare or similar)</p><p>What if the serviceworker intercepted a request to react 16.1 and instead of downloading it, it downloaded that patch between 16.0 and 16.1 and applied it to the cached version of 16.0, because that was a performance gain?</p><p>What if ….?</p><p>I think all of these things are possible doing by switching to `runtime bundling &amp; transpiling` and getting some work into it. Because I’m not saying it’s easy!</p><p>We all want the same thing. Optimal performance for the user. And the use case is almost always the same. it’s html, js and pictures. Sure there are exceptions, and maybe we can provide hints or be able to override. And maybe this is wrong for some apps. But for most users this could be a huge win.</p><p>I think we as developers need to stop thinking on how to optimize the user experience for our site. We are reusing so many lib from npm, that we should think about how to optimal the users experience on the web. And when we do that, I think we should be able to see an increase in the user experience on our site also.</p><p>I’m sure Google and Facebook are doing incredible stuff on caching and optimizing this stuff, they have a lot of $ to save in energy usage! They should really challenge CloudFlare in the caching and optimize delivery game!</p><p>Toughs? Is there anything technical issues you see? Is this the wrong way to approach it ? Would love to get more feedback on the idea, and let it mature to something that is feasible to do.</p><p>My first step was <a href="https://github.com/parcel-bundler/parcel/issues/402">suggesting this as an idea</a> in the parcel issue tracker on github, to get more thought from the develops on parcel, if this is a good way to go down.</p><p>BTW: would love see someone doing the same with webpack :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8c563851400" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debugging Node in VS Code]]></title>
            <link>https://medium.com/@sinsvend/debugging-node-in-vs-code-dc336f20800d?source=rss-7f145f74215d------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc336f20800d</guid>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[debug]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Sindre Øye Svendby ]]></dc:creator>
            <pubDate>Tue, 10 Oct 2017 23:05:19 GMT</pubDate>
            <atom:updated>2017-10-10T23:07:17.446Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Lv2oIqu03j_vKFWgjb0-Q.png" /></figure><p><a href="http://events.linuxfoundation.org/events/node-interactive">Node Interactive </a>was just hold in Vancouver. I was listening to <a href="https://twitter.com/chrisdias">Chris Dias</a> good talk about VS Code and how you can set up tasks, debug it, debug it inside a container and deploy it to a cloud (he show Azure). The Azure + Code integration was amazing, I’m using google cloud, I really hope there comes and extension like that is as good as the one he showed for Azure!</p><p>Anyways, he showed how to debug native node. But our stack is a isomorphic webapp where we are using import and not require. The common way to do this was to use babel to transpile the code down to older ES code.</p><p>But for the people that like to live on the bleeding edge of technology , node 8.5 ships whit the experimental-modules flag. So you can write your modules with native modules support. The problem is that the module is not backward compatible so all people using it most use the flag or wait util a new version of node has it turn on by default.</p><p>In august <a href="https://medium.com/web-on-the-edge/es-modules-in-node-today-32cff914e4b">John-David Dalton announced the release of the std/esm libary</a> that tries to pinpoint this issue. Now you can support both, by adding a small wrapper/proxy around your main entry point.</p><p>So dependent on your context, there exist at least three different setups that could be useful for you when you are debugging.</p><h3>Debug node with std/esm</h3><p>This is so straight forward you want everything to be when we are developing stuff! And the method I would recommend for most cases. You only need to change the main entry point to use the lib. Then you can write esm modules with the file ending .mjs and its backwards compatible with node versions that do not support ESM modules.</p><p>If you are working on and existing project, remember to add the { &quot;esm&quot;: &quot;js&quot; } as the second argument to the lib, so that you unlock the use of import and export with .js files. <br>See <a href="https://github.com/SindreSvendby/debug-node-with-vs-code/blob/master/src/std-esm/index.js#L3">example here</a></p><p>When that is setup push F5 (run debug) in Code. If you need to create the launch.json this is how it should look like:</p><p>{<br> “version”: “0.2.0”,<br> “configurations”: [{<br> “name”: “Launch Program”,<br> “type”: “node”,<br> “request”: “launch”,<br> “program”: “${file}”,<br> }]<br>}</p><h3>Debug with node 8.5+ experimental-modules flag</h3><p>Code are using the file ending to understand what kind of module it is, since the mjs file extension is new and Code is not updated to understand this<br>there exist <a href="https://github.com/Microsoft/vscode-node-debug/pull/161/">several</a> <a href="https://github.com/Microsoft/vscode/search?q=mjs&amp;type=Issues&amp;utf8=%E2%9C%93">issues</a> on this, so if we want to walk down this path, I would recommend using the <a href="https://code.visualstudio.com/insiders/">insiders build</a>.</p><p>So to be able to debug you app with today&#39;s version of Code you need to add #!/usr/bin/env node as first line of your module so that the debugger accept the file as and JS file. Example</p><p>The second thing you need to do is to use ${file} in launcher.json so that it finds the file, if you write the filename it will add a .js to the end and complain that is not able to find the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LcWo_6Oqpeqm7MODGk_L6Q.png" /></figure><p>I was not able to trigger the breakpoints in this code at all, even with this things set, <a href="https://github.com/Microsoft/vscode/issues/33051#issuecomment-332764087">but other people has been able to get this to work</a>. Hopefully the support will be better in Code soon. If you do see a mistake I have done in the setup so I can get the breakpoints to work, I would be eager to hear about it</p><h3><strong>Debug node with babel</strong></h3><p>So I tried to set up it with babel, in general i would say that the <a href="https://code.visualstudio.com/docs/editor/debugging">documentation on VS Code</a> is really good, so I was a bit surprised that I was not able to find any reference on how setup and debug babel on their site.</p><p>So here are the gotchas I got when trying to get it to work with babel:</p><ul><li>Remember to <a href="https://github.com/SindreSvendby/debug-node-with-vs-code/blob/master/package.json#L5">add </a><a href="https://github.com/SindreSvendby/debug-node-with-vs-code/blob/master/package.json#L5">--source-maps in babel config</a></li><li>Remember to <a href="https://github.com/SindreSvendby/debug-node-with-vs-code/blob/master/src/babel/index.js#L2">add </a><a href="https://github.com/SindreSvendby/debug-node-with-vs-code/blob/master/src/babel/index.js#L2">babel-pollyfill</a> when changing to babel from babel-node</li><li>Remember to <a href="https://github.com/SindreSvendby/debug-node-with-vs-code/blob/master/.vscode/launch.json#L17">add a preLaunchTask</a> so you are not running against all files.</li><li><a href="https://github.com/SindreSvendby/debug-node-with-vs-code/blob/master/.env">Env var file</a> can not contain export syntax if used as a <a href="https://github.com/SindreSvendby/debug-node-with-vs-code/blob/master/.vscode/launch.json#L19">envFile attribute in lanuch</a></li></ul><p>See the <a href="https://github.com/SindreSvendby/debug-node-with-vs-code/blob/master/.vscode/launch.json#L13">launch.json</a> for details on the debugger settings for babel. And remember that here you are transpiling the code back to and older format that most likely is running slow and you have a inserted babel as extra complexity, it could be correct for your use case, but be sure it is, and that your are not just stuck with old habits.</p><h3>Mathias Bynens on Twitter</h3><p>New ECMAScript features are often more than just &quot;sugar&quot; - they tend to enable optimizations at the engine level. Don&#39;t transpile them away! https://t.co/5UOP4pjmsH</p><p>F|or a working example on all of these example check out the <a href="https://github.com/SindreSvendby/debug-node-with-vs-code">github repo</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc336f20800d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>