<?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 Varun Mulloli on Medium]]></title>
        <description><![CDATA[Stories by Varun Mulloli on Medium]]></description>
        <link>https://medium.com/@mulloli?source=rss-51353c292f85------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*OB3M9GfHeKTL5heM.</url>
            <title>Stories by Varun Mulloli on Medium</title>
            <link>https://medium.com/@mulloli?source=rss-51353c292f85------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 11:35:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mulloli/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[Tutorial — Getting started with ReasonReact]]></title>
            <link>https://javascript.plainenglish.io/tutorial-getting-started-with-reasonreact-984069b898ac?source=rss-51353c292f85------2</link>
            <guid isPermaLink="false">https://medium.com/p/984069b898ac</guid>
            <category><![CDATA[reasonml]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reasonreact]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[bucklescript]]></category>
            <dc:creator><![CDATA[Varun Mulloli]]></dc:creator>
            <pubDate>Tue, 14 Apr 2020 16:30:51 GMT</pubDate>
            <atom:updated>2020-04-16T18:53:47.159Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MfzqROVYhM9RZzdjEQ_-8Q.png" /></figure><h3>Getting started with ReasonReact</h3><p>In this blog post, we’ll get our hands dirty building a small CRUD application using ReasonReact. We’ll cover the following in this tutorial:</p><ul><li>Styling with <a href="https://github.com/reasonml-labs/bs-css">bs-css</a></li><li>JSON encoding/decoding with <a href="https://github.com/glennsl/bs-json">@glennsl/bs-json</a></li><li>LocalStorage operations</li><li>Using the <strong>useReducer </strong>hook</li></ul><p>For those who would like to see the code first, the Github link is here.</p><p><a href="https://github.com/varunmulloli/reasonreact-example-list">varunmulloli/reasonreact-example-list</a></p><h4>Directory Structure</h4><pre>reasonml-example-list/<br>|<br>|- public/<br>|  |- edit.png<br>|  |- delete.png<br>|- src/<br>|  |- apis/<br>|  |  |- ListAPI.re<br>|  |- components/<br>|  |  |- header/<br>|  |  |  |- Header.re<br>|  |  |  |- HeaderCSS.re<br>|  |  |- listItems/<br>|  |  |  |- ListItems.re<br>|  |  |  |- ListItemsCSS.re<br>|  |  |- modal/<br>|  |  |  |- Modal.re<br>|  |  |  |- ModalCSS.re<br>|  |- helpers/<br>|  |  |- JsonHelper.re<br>|  |- services/<br>|  |  |- ListService.re<br>|  |- theme/<br>|  |  |- Theme.re<br>|  |- types/<br>|  |  |- Types.re<br>|  |- App.re<br>|  |- Index.re<br>|<br>|- bsconfig.json<br>|- index.html<br>|- package.json<br>|- watcher.js</pre><p>I know the file organization is a bit overkill for a demo application as basic as this one, but I believe this would be a good starting point for building bigger applications so I did not bother to simplify it.</p><h4>Installation</h4><p>If you don’t have <a href="https://nodejs.org/"><strong>Node.js</strong></a> already installed on your machine, you can download and install it from <a href="https://nodejs.org/en/download/">the Node.js website</a>. Once installed, run the following command on your command line/terminal to install <a href="https://bucklescript.github.io/">Bucklescript</a> which is responsible for compiling your <a href="https://reasonml.github.io/">ReasonML </a>code to Javascript.</p><pre>npm install --global bs-platform@6.2.1</pre><p>Once these steps are successfully done, navigate to the folder where you intend to start this project and create these two files — <strong><em>package.json</em></strong> and <strong><em>bsconfig.json</em></strong>.</p><blockquote>package.json</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f61459bfe6ae92606c5e4e07e6c4c66/href">https://medium.com/media/4f61459bfe6ae92606c5e4e07e6c4c66/href</a></iframe><blockquote>bsconfig.json</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/69dc2b19168aa284e75c57b6ee5e28ae/href">https://medium.com/media/69dc2b19168aa284e75c57b6ee5e28ae/href</a></iframe><p>Make sure your current working directory is the same in your command line and install all the dependencies by running</p><pre>npm install</pre><h4>Hello World</h4><p>Now we’ll setup the files required to run a “Hello World” from our ReasonReact app. I’m using the same server setup that you get when you run the bsb -init command.</p><blockquote>index.html</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a4c3e80b1fcff8ba040ba05c2c766e3/href">https://medium.com/media/2a4c3e80b1fcff8ba040ba05c2c766e3/href</a></iframe><blockquote>watcher.js</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c66525ab6549a3df4b7b5ce0beea809d/href">https://medium.com/media/c66525ab6549a3df4b7b5ce0beea809d/href</a></iframe><blockquote>src/Index.re</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c0224a0ad43f293c51c1dcd077f6d15/href">https://medium.com/media/9c0224a0ad43f293c51c1dcd077f6d15/href</a></iframe><p>Once these files are created, go back to the command line and run</p><pre>npm run start</pre><p>This command will compile the code and also watches for changes. Now open a new tab/window for the command line, ensure you’re in the same working directory and run</p><pre>npm run server</pre><p>This will bring up the server on port 8000. We can check the output by opening the browser and navigating to <a href="http://localhost:8000/">http://localhost:8000</a>. If all goes well, you’ll see “Hello World” on your browser window.</p><h4>Styling with <a href="https://github.com/reasonml-labs/bs-css">bs-css</a></h4><p>Now that we’ve completed the setup phase, we’ll move on to building the app step by step. First we’ll make a component and style it using <strong><em>bs-css</em></strong>. Modify the contents of <strong>src/Index.re</strong> to this:</p><blockquote>src/Index.re</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/71c8d6e31180d86d0925be6257fcf640/href">https://medium.com/media/71c8d6e31180d86d0925be6257fcf640/href</a></iframe><blockquote>src/App.re</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88df77dec86fb4e46de2216770a0ee23/href">https://medium.com/media/88df77dec86fb4e46de2216770a0ee23/href</a></iframe><blockquote>src/theme/Theme.re</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c7c45981823c32faa82b32eb5084574/href">https://medium.com/media/8c7c45981823c32faa82b32eb5084574/href</a></iframe><blockquote>src/components/header/Header.re</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c2ad1210fc46826013ff74469433faea/href">https://medium.com/media/c2ad1210fc46826013ff74469433faea/href</a></iframe><blockquote>src/components/header/HeaderCSS.re</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/33e8afcdc638e09bb24790b27954a157/href">https://medium.com/media/33e8afcdc638e09bb24790b27954a157/href</a></iframe><p>Notice that we’ve separated the global and common styles into a separate theme file so that it can be easily shared across other CSS modules. Since the watcher is running, your browser will automatically refresh and load the output of our newly written code on save. If all goes well, the browser window will now display our newly created header.</p><h4>JSON encoding/decoding with @glennsl/bs-json</h4><p>Our app aims at manipulating a list of objects, and we plan to do this by creating records at Reason end and store it as a JSON string in localStorage for persistence. Now we’ll define the record types and write the JSON encode and decode functions for it.</p><blockquote>src/types/Types.re</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b79dcbdb1310dc4e88caf0600018c596/href">https://medium.com/media/b79dcbdb1310dc4e88caf0600018c596/href</a></iframe><blockquote>src/helpers/JsonHelper.re</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/880fab25e496854d2b2c3250579d39b8/href">https://medium.com/media/880fab25e496854d2b2c3250579d39b8/href</a></iframe><h4><strong>LocalStorage operations</strong></h4><p>Now we’ll move on to defining the localStorage CRUD operations for these records using the JSON encoders and decoders that we just created.</p><blockquote>src/services/ListService.re</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c288059d5f374986dbb3f77aca5980c/href">https://medium.com/media/7c288059d5f374986dbb3f77aca5980c/href</a></iframe><blockquote>src/apis/ListAPI.re</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/afd2d9e0f44c4c28f9773e158c182b68/href">https://medium.com/media/afd2d9e0f44c4c28f9773e158c182b68/href</a></iframe><p>The module signature for ListService will control what all methods are exposed through its implementation modules.</p><h4>Using the <strong>useReducer </strong>hook</h4><p>Now we’ll use the APIs we created to wire up the application. The only part that’s remaining is building the actual UI itself, which is what we are going to do now. Let’s go back to our <strong>src/App.re</strong> that we’ve created earlier and update its contents.</p><blockquote>src/App.re</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c687b751ec8c29e5307404931b0dc8ee/href">https://medium.com/media/c687b751ec8c29e5307404931b0dc8ee/href</a></iframe><blockquote>src/components/listItems/ListItems.re</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b56404a621eaabb84e2368faf8bf20c1/href">https://medium.com/media/b56404a621eaabb84e2368faf8bf20c1/href</a></iframe><blockquote>src/components/listItems/ListItemsCSS.re</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a03aee736fbf325f66272d245ae23fbd/href">https://medium.com/media/a03aee736fbf325f66272d245ae23fbd/href</a></iframe><blockquote>src/components/modal/Modal.re</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e269a8b90a2a813758824cb69017dff/href">https://medium.com/media/4e269a8b90a2a813758824cb69017dff/href</a></iframe><blockquote>src/components/modal/ModalCSS.re</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/66f9bdea28180671ee866c6f2de49d89/href">https://medium.com/media/66f9bdea28180671ee866c6f2de49d89/href</a></iframe><p>This completes the code for our sample ReasonReact app. One thing to note is that React.useEffect0(effect) will run only once for this application during the initial render because it is equivalent to calling React.useEffect(effect, []) in React. So Fetch is not dispatched every time the component re-renders.</p><p>I hope this blog post is helpful to you. All suggestions/feedback/criticism are welcome! :)</p><h4><strong>A note from JavaScript In Plain English</strong></h4><p>We have launched three new publications! Show some love for our new publications by following them: <a href="https://medium.com/ai-in-plain-english"><strong>AI in Plain English</strong></a>, <a href="https://medium.com/ux-in-plain-english"><strong>UX in Plain English</strong></a>, <a href="https://medium.com/python-in-plain-english"><strong>Python in Plain English</strong></a><strong> </strong>— thank you and keep learning!</p><p>We are also always interested in helping to promote quality content. If you have an article that you would like to submit to any of our publications, send us an email at <a href="/service/mailto:submissions@plainenglish.io"><strong>submissions@plainenglish.io</strong></a><strong> </strong>with your Medium username and we will get you added as a writer. Also let us know which publication/s you want to be added to.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=984069b898ac" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/tutorial-getting-started-with-reasonreact-984069b898ac">Tutorial — Getting started with ReasonReact</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My 2017 Kawasaki Ninja 300 (KRT Edition)— Ownership Blog]]></title>
            <link>https://medium.com/series/my-2017-kawasaki-ninja-300-krt-edition-ownership-blog-f08841d3075f?source=rss-51353c292f85------2</link>
            <guid isPermaLink="false">https://medium.com/p/f08841d3075f</guid>
            <dc:creator><![CDATA[Varun Mulloli]]></dc:creator>
            <pubDate>Wed, 10 Jan 2018 13:30:13 GMT</pubDate>
            <atom:updated>2018-01-10T13:30:13.573Z</atom:updated>
            <content:encoded><![CDATA[<h4>Quick History</h4><p>I learned the basics of riding a motorcycle in college, but I couldn’t afford to own one at that time. So the first thing I did after getting my first paycheque was to get one immediately. Found a used Yamaha FZ-S in excellent condition through one of my friend’s connections and a few weeks later it was all mine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pNEhwCQTx3Jbkszc5PGZDA.jpeg" /></figure><p>It was a simple air-cooled 150cc single cylinder street bike and it unlocked a whole new life for me. Rode it long and hard, crashed it multiple times, learned to do basic maintenance works – simply put, had plenty of fun with it.</p><p>The piston rings started to wear off at 60k kilometres and an engine rebuild was due. I decided to shell out some money and went with the 180cc big-bore kit from <a href="http://raceconcepts.in/">RaceConcepts</a> along with their carburettor and intake mods. The upgrades were super effective and I found myself doing even more longer rides.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dMBCbm6PeJgZ1FAzqItCBw@2x.jpeg" /></figure><p>On reaching home after a 4200km trip to the Himalayas, I decided that it was time to upgrade to a bigger bike. Two months later, I sold my FZ.</p><blockquote>The FZ served me well for 2.5 years and 35k kilometres and has never let me down anywhere during my entire ownership period. It was an absolute gem of a bike to own.</blockquote><h4>Deciding what to buy</h4><p>It was almost certain that I’ll be going for the KTM RC 390 as my next bike as it was the most bang-for-buck sports bike option available here in India. But I convinced myself that I won’t jump into conclusions right away.</p><p>There were plenty of KTM dealerships in Bangalore so I started off with the one closest to me. I went there on a Saturday evening and found that the test bike wasn’t available at that time. So I took an appointment on Monday afternoon and spent the rest of the time there gawking at the display piece.</p><p>On Monday I went to the showroom after receiving a call from them. The guy there was ready for me with the bike and he told me about the route I’ve to take and handed me the keys. The route was simple — a straight, followed by a u-turn, another straight, and a u-turn back to the showroom.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SvVVyyP_Mgb6Zw_DXWma9g.jpeg" /></figure><p>I should say it’s impossible to judge a bike by taking a ride for just 1.6km but what glaringly stood out for me was the vibrations from the bike. I did not expect this at all. I’ve ridden my friend’s Duke 200 extensively and I absolutely love the way it rides. So naturally I expected a similar experience from this bike as well, albeit more power on tap.</p><p>But because of this I wasn’t satisfied with the test ride even though the bike felt brilliant in other aspects — the posture, the weight balance, gear shifts and the brakes. I wanted to know if the buzz is peculiar to that particular test bike only or is the characteristic of the model itself. So I decided to take another test ride from a different KTM showroom and confirm it myself.</p><h4>Daring to stretch the budget</h4><p>Almost a month has passed since I took my first test drive of the RC390 and I haven’t found the time to do another one. All this while, the thought of vibrations started getting into my head and overshadowed all the other niceties of the RC. And this eventually lead me into taking a test ride of the Kawasaki Ninja 300.</p><p>The Ninja had comparable specs to the RC but was way too expensive even though RC trumped in almost all fields in the spec-sheet battle. I had the budget to afford it but the thought of getting more stuff for less money meant I didn’t even consider it in my shortlist.</p><p>The test drive of the baby Ninja took place in heavy traffic, and all I could do was just one overtaking manoeuvre to get the revs up.</p><blockquote>I was completely smitten by the way the bike behaved.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dMXZxLM8It8OCdXJs3CnYw.jpeg" /><figcaption>The test ride route</figcaption></figure><p>When the road opened up a bit I gave it the gas while in 2nd gear — it pulled really hard, shifted to 3rd, still pulled hard, shifted to 4th and calmed down. The bike felt absolutely incredible. It was a bit on the heavier side but was a reassuring weight. The ride quality was excellent and the ergonomics are spot on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AnSrLHjyvxIStYuSaYMn1A.jpeg" /><figcaption>Bangalore traffic. Ugh.</figcaption></figure><p>The plans of taking a test ride of the RC390 from the KTM showroom next door went down the drain right after this test ride. I was completely powerless. The Ninja had me.</p><h4>The booking and delivery</h4><p>I really took my time to contemplate on this purchase — a week to be precise. I thought I would be able to think more clearly once the adrenaline and the excitement wears off. Needless to say that it did nothing to bring me back to my senses. Motorcycles did not make any sense anyway. So I’d better be off with the one I desire the most.</p><p>The next weekend I went to the showroom to pay the booking amount. The sales guy said he’ll inform me once the bike reaches the warehouse and then I can make the full payment so that he can invoice it and send it for registration. I had no intentions going to the RTO so I decided to take the delivery after the full registration process is completed.</p><p>The entire process took 2 weeks and I finally got the beast delivered on the 24th of December 2017. A small cake cutting ceremony was held and they gave me a t-shirt and a coffee mug along with the bike.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aPJ5dKzUW14sSfeYNk9f0g.jpeg" /></figure><p>The dealer was offering a riding jacket for free with the bike. I already had a good one with me and this one was pretty basic so I asked the sales guy if he could offer me some accessories for the bike instead of the jacket. He said he could provide me with an R&amp;G radiator guard and tank pad instead and I readily agreed. I got them installed on the bike before the delivery.</p><p>They also had the R&amp;G down-pipe grill in stock in the showroom so I purchased that one as well. But the installation would require removal of the fairings so we decided to get it done during the first service.</p><p>Soon I was off to my home carefully navigating through the Bangalore traffic grinning from ear to ear under my helmet. A new chapter in my life has begun!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f08841d3075f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular 2 with ES6 — The 5 minute Quickstart]]></title>
            <link>https://medium.com/angular-2-with-es6/angular-2-with-es6-the-5-minute-quickstart-a9e4eb0bffcc?source=rss-51353c292f85------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9e4eb0bffcc</guid>
            <category><![CDATA[angular2]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[es6]]></category>
            <dc:creator><![CDATA[Varun Mulloli]]></dc:creator>
            <pubDate>Fri, 18 Mar 2016 18:03:53 GMT</pubDate>
            <atom:updated>2016-04-08T08:49:19.204Z</atom:updated>
            <content:encoded><![CDATA[<p>This tutorial does exactly what the <a href="https://angular.io/docs/js/latest/quickstart.html">5 Minute Quickstart</a> tutorial on the Angular 2 website does — building a “Hello World!” app. The only difference is that we’ll be doing this in ES6 Javascript while the Angular 2 website features tutorials only in TypeScript, Javascript (ES5) and Dart.</p><p>Not all of the ES6 features are supported out of the box by the browsers out there today. So we will have to transpile our ES6 code to ES5 so that it could run seamlessly on our current browsers. There are several tools out there that could do this task, and for this tutorial, we’ll be using <a href="https://babeljs.io/">Babel</a>.</p><p>We’ll also bundle all of our source javascript files into one single file using a module bundling tool called W<a href="https://webpack.github.io/">ebpack</a>. Support for Babel through Webpack is available in the form of plugins, and we’ll use them to automate the transpilation task. This means once we configure these plugins, we just have to write ES6 code and Webpack will take care of the rest.</p><p>The source code for this tutorial is hosted on Github.</p><p><a href="https://github.com/varunmulloli/angular2-quickstart-es6-webpack">varunmulloli/angular2-quickstart-es6-webpack</a></p><h4>Directory structure</h4><pre>angular2-quickstart-es6-webpack/<br>|<br>|- public/<br>|  |- dist/<br>|  |- src/ <br>|     |- app/<br>|     |  |- app.component.js<br>|     |  |- main.js<br>|     |<br>|     |- index.js<br>|<br>|- index.html<br>|- package.json<br>|- webpack.config.js</pre><h4><em>package.json</em></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/287a3847a56511b8edebd6e1ff34c055/href">https://medium.com/media/287a3847a56511b8edebd6e1ff34c055/href</a></iframe><p>The <em>package.json</em> file is very similar to the one featured in the original Quickstart tutorial using Javascript ES5. The extra dependencies are:</p><ul><li><em>babel-core</em> — Our transpilation tool.</li><li><em>webpack — </em>Our module bundling tool.</li><li><em>babel-loader —</em> Webpack plugin for Babel.</li><li><em>babel-preset-es2015 — </em>Babel’s collection of ES6 transforms.</li><li><em>script-loader — </em>Webpack plugin for adding external Javascript libraries into our bundled code so that we don’t have to include them separately in a &lt;script&gt; tag on our HTML page.</li></ul><h4>Installation</h4><p>If you don’t have <a href="https://nodejs.org/"><strong>Node.js</strong></a> already installed on your machine, you can download and install it from <a href="https://nodejs.org/en/download/">the Node.js website</a>. Once installed, you may verify your installation by typing the following on your command line/terminal.</p><pre>npm -v</pre><p>At the time of writing this, my npm version was 3.8.2.</p><p>To make use of the command line tools of Webpack, we’ll install it as a global module. Run the following command on your machine:</p><pre>npm install webpack -g</pre><p>The <em>-g</em> flag specifies the installation as global. Now let’s navigate to our project root directory and install all the dependencies for the project.</p><pre>cd /path/to/angular2-quickstart-es6-webpack/<br>npm install</pre><p>Once the installation is complete, all the dependencies specified in our <em>package.json</em> will be downloaded to <em>node_modules/ folder.</em></p><h4><em>webpack.config.js</em></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d4d06dbeb7163f7a6aa27d516f98402e/href">https://medium.com/media/d4d06dbeb7163f7a6aa27d516f98402e/href</a></iframe><p>This is our configuration file for Webpack. We have defined the entry point as <em>public/src/index.js</em> and it will resolve all the dependencies referenced by it recursively and the output bundle will be created as <em>vendor.js </em>at<em> public/dist/</em> folder. This is the only file that we need to include in our HTML file.</p><p>The <em>devtool: ‘source-map’</em> configuration generates source maps, which helps in the mapping of combined and minified source files to their original state, and is useful for debugging purposes.</p><p>The <em>babel-loader</em> configuration with <em>es2015</em> preset is responsible for the transpilation task. If you want to know more about how to configure Babel with Webpack, here’s a great tutorial:</p><p><a href="http://jamesknelson.com/using-es6-in-the-browser-with-babel-6-and-webpack/">Using ES6 and ES7 in the Browser, with Babel 6 and Webpack</a></p><h4>public/src/app/app.component.js</h4><p>This file contains our visual component for our app, named <strong>AppComponent</strong>. ES6 does not support the annotation syntax that TypeScript uses for Angular 2 for representing class metadata. Instead it is done by defining a static get method called <em>annotations</em> inside the class and returning them as an array of objects.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/12745e33a170e119a68cd662a59c6fbd/href">https://medium.com/media/12745e33a170e119a68cd662a59c6fbd/href</a></iframe><p>The same behaviour can be achieved through defining a static property on the class named <em>annotations</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e44c639045dac948df38d898d7c7368/href">https://medium.com/media/9e44c639045dac948df38d898d7c7368/href</a></iframe><h4>public/src/app/main.js</h4><p>This is where the bootstrapping logic of the app resides.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2753a2396816523f01a2842ecf4ea8ce/href">https://medium.com/media/2753a2396816523f01a2842ecf4ea8ce/href</a></iframe><p>We could’ve added the bootstrapping logic to <em>app.component.js</em>, but instead we created a separate file called <em>main.js. </em>This is because a component’s responsibility is to present and manage a view, not launching the application. Those two are different concerns. Also this pattern helps in testability and reusability of the code as well.</p><h4><em>public/src/index.js</em></h4><p>This file is our entry point to Webpack.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/704b646f17bfdf635a955c3912cfe47d/href">https://medium.com/media/704b646f17bfdf635a955c3912cfe47d/href</a></iframe><p>Along with our <em>main.js</em> file, we’ll add all the libraries that were loaded using &lt;script&gt; tags in the <em>index.html</em> file in the original tutorial, and they’ll be loaded using Webpack’s <em>script-loader</em> plugin. The <strong>!!script!</strong> is a special flag that will inline the script in our bundle, equivalent to using a &lt;script&gt; tag in HTML.</p><p>Webpack reads this file, resolve all the dependencies referenced by it recursively and the outputs the bundled Javascript file.</p><h4>index.html</h4><p>This is the HTML page loaded by our browser.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53c324cbeb182e318d2eb3b2bc2d1aa7/href">https://medium.com/media/53c324cbeb182e318d2eb3b2bc2d1aa7/href</a></iframe><p>Bundling of modules gets rid of all the &lt;script&gt; and &lt;link&gt; tags in our <em>index.html</em> file. Note that the <em>public/dist/vendor.js</em> file doesn’t exist yet. Our app is now complete and now we’ll go ahead and create the <em>vendor.js</em> file.</p><h4>Creating the vendor.js file</h4><p>To create the output bundle, navigate to your project root directory and run the Webpack command on your command line.</p><pre>cd /path/to/angular2-quickstart-es6-webpack/<br>webpack --progress</pre><p>If successful, two new files will be created inside <em>public/dist/ </em>directory, viz. <em>vendor.js</em> and <em>vendor.js.map</em>. The latter is the source map file.</p><h4>Running the app</h4><p>Assuming you are still in the project root directory, run the command</p><pre>npm start</pre><p>This will trigger the <em>lite-server</em> and it will load <em>index.html</em> on a browser window automatically. Now you should be able to see <strong>My First Angular 2 App</strong> on the browser window.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9e4eb0bffcc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/angular-2-with-es6/angular-2-with-es6-the-5-minute-quickstart-a9e4eb0bffcc">Angular 2 with ES6 — The 5 minute Quickstart</a> was originally published in <a href="https://medium.com/angular-2-with-es6">Angular 2 with ES6</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>