<?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 Luke Boyle on Medium]]></title>
        <description><![CDATA[Stories by Luke Boyle on Medium]]></description>
        <link>https://medium.com/@3stacks?source=rss-3f3b9c0b9004------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rpnrZxAj776AsuUbpZqDIQ.png</url>
            <title>Stories by Luke Boyle on Medium</title>
            <link>https://medium.com/@3stacks?source=rss-3f3b9c0b9004------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 16:46:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@3stacks/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[Rollup vs Webpack (JavaScript bundling in 2018)]]></title>
            <link>https://medium.com/jsdownunder/rollup-vs-webpack-javascript-bundling-in-2018-b35758a2268?source=rss-3f3b9c0b9004------2</link>
            <guid isPermaLink="false">https://medium.com/p/b35758a2268</guid>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[parcel]]></category>
            <category><![CDATA[rollup]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[bundling]]></category>
            <dc:creator><![CDATA[Luke Boyle]]></dc:creator>
            <pubDate>Thu, 22 Feb 2018 04:11:07 GMT</pubDate>
            <atom:updated>2018-02-22T04:11:07.932Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2IGjvDrmofi7h9j5fPGvPw.png" /></figure><p>Although tooling standards have begun to stabilise in JavaScript land, there’s still a bit of confusion around the right tool for the job. This is a somewhat detailed comparison between Rollup and Webpack. Let’s start by comparing their respective configuration files.</p><h3>Configuration</h3><h4>rollup.config.js</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3003da6731d80e3904be774f7bbb340/href">https://medium.com/media/f3003da6731d80e3904be774f7bbb340/href</a></iframe><h4>webpack.config.js</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f941bd1ffaced28f93f553028235d29/href">https://medium.com/media/4f941bd1ffaced28f93f553028235d29/href</a></iframe><p>Quick differences to note:</p><p>Rollup has node polyfills for import/export, whereas webpack doesn’t</p><p>Rollup has support for relative paths, whereas webpack does not, so we either use path.resolve or path.join</p><p>Rollup requires you have modules set to false on es2015 presets, because it will process modules as ES2015 if it can and do scope hoisting magic before transpiling the module.</p><p>Let’s take a very simple example:</p><h4>some-file.js</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9850bc01cf934efd932a9ee76ee07ee/href">https://medium.com/media/a9850bc01cf934efd932a9ee76ee07ee/href</a></iframe><h4>index.js</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5db269c07b451d27abfee4caa056d00e/href">https://medium.com/media/5db269c07b451d27abfee4caa056d00e/href</a></iframe><p>What would you expect the output of this be?</p><p>This is arguably where Rollup shines. For simpler modules, it returns a very efficiently transformed, minimal bundle, whereas Webpack has a lot of magic™ included in the bundle.</p><h4>bundle.rollup.js — ~245 bytes</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e128077f29f94287e99b7d46d3805d33/href">https://medium.com/media/e128077f29f94287e99b7d46d3805d33/href</a></iframe><h4>bundle.webpack.js — ~4108 bytes</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3d761fae007a7483e2ed7df271eed0d/href">https://medium.com/media/f3d761fae007a7483e2ed7df271eed0d/href</a></iframe><p>In the Webpack bundle, the actual imports occur on around line ~100. If you navigate to this point, you will see that the actual module code is <strong>mostly </strong>the same (below), with the biggest difference being that in the Webpack bundle, each module is wrapped in a function which can be internally invoked. This is why Webpack bundles are considered to be ‘safer’ for larger/more complex applications.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95c08f587cff426ff98701ba4132a1a0/href">https://medium.com/media/95c08f587cff426ff98701ba4132a1a0/href</a></iframe><p>A lot of the mess is removed in production mode builds and the bundle size.</p><p>So, how do you tell which one is right for you? In recent history, the conventional wisdom has been:</p><blockquote><strong><em>“Use webpack for apps, and Rollup for libraries”</em></strong></blockquote><p>However, it’s becoming more difficult to justify this as a rule. Webpack enhancements have really levelled the playing field in terms of general bundling efficiency, and Rollup recently added <a href="https://medium.com/rollup/rollup-now-has-code-splitting-and-we-need-your-help-46defd901c82">code splitting</a> (the major lacking features between the two).</p><p>To make a real life parallel, I’d compare this bundler battle to the product design theory called the “Kano model”. The Kano model essentially states that “over time, delightful innovation becomes another basic need”.</p><p>Take for example the arrow on the fuel gauge of a car to indicate which side to face the fuel pump (figure 1). When the idea was conceived, it was considered to be a great innovation, however, now it is simply an expectation amongst users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*rrQDKg7mEK5ty-a_." /><figcaption>Fig 1: Fuel cap side indicator</figcaption></figure><p>To see the real differentiating features, we have to go back to the wild west of 2016.</p><h3>Rollup (circa 2016)</h3><h4>Pros:</h4><ul><li>Tree shaking (live code inclusion / dead code elimination)</li><li>esnext:main entry in package.json to import es2015+ (renamed to ‘module’)</li><li>Scope hoisting</li><li>Simple API</li></ul><h4>Cons:</h4><ul><li>Limited support for alternative file type loading (css, images etc)</li><li>No code splitting</li></ul><h3>Webpack (circa 2016)</h3><h4>Pros:</h4><ul><li>Advanced support for CSS/HTML/image loading</li><li>Code splitting</li><li>Hot module replacement for super fast dev builds</li></ul><h4>Cons:</h4><ul><li>No tree shaking</li><li>No Scope hoisting</li><li>No native support for ES2015+ modules</li><li>Complicated API</li></ul><p>A lot has changed since then (the above is not an exhaustive list, and both of the libraries have additional pros and cons I couldn’t possibly list), and both libraries have taken cues from one another. The community surrounding both libraries has also grown which has helped accelerate the implementation of novel features.</p><h3>Rollup (now) — What’s changed?</h3><ul><li>Rich ecosystem of plugins for file loading/dev servers</li><li>Code splitting (Added 8th of Feb 2018 after a 2 year wait! 🎉🎉)</li></ul><h3>Webpack (now) — What’s changed?</h3><ul><li>Tree shaking &amp; ES2015+ module support (Added in Webpack 2)</li><li>Scope hoisting (Added in Webpack 3)</li><li>Support for esnext:main / module</li></ul><p>In my opinion, you should still probably prefer Rollup for libraries, but the option of using Rollup for large apps is much more realistic now. One thing’s for sure, both Webpack and Rollup are here to stay. I’d say the main reason for the staying power of these two libraries is the amazing internal teams and the unending effort they put into maintaining them and answering issues and StackOverflow questions.</p><p>For a more detailed comparison of the internals of the two libraries, Rich Harris (creator of Rollup) has a great writeup <a href="https://medium.com/webpack/webpack-and-rollup-the-same-but-different-a41ad427058c">here</a>.</p><h3>BONUS: A challenger approaches</h3><p><a href="https://parceljs.org/">Parcel</a> is a new and interesting bundler that has many of the same features as Rollup and Webpack (e.g. code splitting and asset loading), but the big feature it’s touting is a zero-configuration get up and go solution for bundling. If you were around in the community in 2015, you’d remember the infamous blog post <a href="https://medium.com/@ericclemmons/javascript-fatigue-48d4011b6fc4">“JavaScript Fatigue”</a>. One of the points the author makes is our tooling was just a mess, and it was. The world hadn’t decided which tools we should be using so most of my projects were a mixture of Gulp, browserify (with babelify) and getting started was never easy.</p><p>With Parcel, the selling point is that you have an index.html file which points to a JavaScript entry, and you can just run parcel index.html and have a fancy dev server running in moments. It also brags that it has blistering fast bundle speeds (though their comparison table omits a Rollup comparison, so I can only assume they are similar).</p><p>If Parcel proves to have the staying power as Webpack/Rollup, I’m sure we’ll see many of the zero configuration features bubble to the surface in those libraries.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b35758a2268" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jsdownunder/rollup-vs-webpack-javascript-bundling-in-2018-b35758a2268">Rollup vs Webpack (JavaScript bundling in 2018)</a> was originally published in <a href="https://medium.com/jsdownunder">jsdownunder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using the Generic Sensors API today]]></title>
            <link>https://medium.com/@3stacks/using-the-generic-sensors-api-today-3293e964d3e2?source=rss-3f3b9c0b9004------2</link>
            <guid isPermaLink="false">https://medium.com/p/3293e964d3e2</guid>
            <category><![CDATA[chrome]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Luke Boyle]]></dc:creator>
            <pubDate>Thu, 28 Sep 2017 06:22:13 GMT</pubDate>
            <atom:updated>2017-09-28T06:22:13.294Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<p>Specification (WD): <a href="https://www.w3.org/TR/generic-sensor/">https://www.w3.org/TR/generic-sensor/</a></p><p>Google Chrome recently made the sensor API available to use under the flag “Generic Sensor” (chrome://flags/#enable-generic-sensor) for Chrome users.</p><p>You can enable this on your PC, but you probably won’t get any use out of it because most desktop machines don’t have the sensors available. You’ll be able to initialise the sensor, but you won’t get any readings from it. To use the sensors, you’ll need to enable the flag on your phone and get a secure tunnel going to your test code (I used ngrok and MAMP for my web server).</p><p>index.js</p><pre><strong>function </strong>handleReading(e) {<br>   <strong>const </strong>container = document.getElementById(&#39;root&#39;);<br><br>   console.log(e);<br>   container.innerHTML = `${e.target.x}, ${e.target.y}, ${e.target.z}`;<br><br>(() =&gt; {<br>   <strong>const </strong>sensor = <strong>new </strong>Accelerometer();<br><br>   sensor.addEventListener(&#39;reading&#39;, handleReading);      <br>   sensor.start();<br>})();</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*jmxiCcTk50vLkTWcJGFwTw.png" /><figcaption>The output of my phone Accelerometer at rest.</figcaption></figure><p>Notably, the event we logged in the handleReading function has a target property which is the sensor we instantiated.</p><p>An activated sensor looks something like this:</p><pre>Accelerometer | Gyroscope {<br>  activated:true<br>  onactivate:null<br>  onerror:null<br>  onreading:null<br>  timestamp:424088067.93500006<br>  x:0.0002593994140625<br>  y:-0.0002593994140625<br>  z:0<br>}</pre><p>The x, y and z values are present in the Accelerometer, Gyroscope but the Accelerometer refers to the acceleration around the x, y and z axes whereas the Gyroscope refers to the velocity on the aforementioned axes.</p><p>There are several sensor interfaces currently available in Chrome, namely:</p><p><strong>Motion sensors:</strong></p><ul><li>Accelerometer</li><li>Gyroscope</li><li>LinearAccelerationSensor</li><li>AbsoluteOrientationSensor</li><li>RelativeOrientationSensor</li></ul><p><strong>Environmental sensors:</strong></p><ul><li>AmbientLightSensor</li><li>Magnetometer</li></ul><p>For more information about these specific interfaces, you can see the specs here:</p><ul><li><a href="https://w3c.github.io/accelerometer/">Accelerometer</a></li><li><a href="https://w3c.github.io/gyroscope/">Gyroscope</a></li><li><a href="https://w3c.github.io/orientation-sensor/">Orientation Sensor</a></li></ul><h3>Potential Applications</h3><ul><li>Web-based velocity/acceleration games</li><li>Web-based 3D demos for mobile (e.g. real estate)</li><li>More powerful/accurate device gestures</li></ul><p>The benefit of this generic interface is that browsers can begin implementing device sensors and they will all follow the same generic sensor API, so it will make it easier to add support for these device sensors in the future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3293e964d3e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>