<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nitish Dayal</title>
    <description>The latest articles on DEV Community by Nitish Dayal (@nitishdayal).</description>
    <link>https://dev.to/nitishdayal</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F786%2F14283798.jpeg</url>
      <title>DEV Community: Nitish Dayal</title>
      <link>https://dev.to/nitishdayal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nitishdayal"/>
    <language>en</language>
    <item>
      <title>Setting Up VS Code and iTerm on M1 Macs</title>
      <dc:creator>Nitish Dayal</dc:creator>
      <pubDate>Mon, 14 Dec 2020 13:42:01 +0000</pubDate>
      <link>https://dev.to/nitishdayal/setting-up-vs-code-and-iterm-on-m1-macs-37g7</link>
      <guid>https://dev.to/nitishdayal/setting-up-vs-code-and-iterm-on-m1-macs-37g7</guid>
      <description>&lt;p&gt;Let's answer some questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Why are you writing this?&lt;/strong&gt;&lt;br&gt;
Because some stuff doesn't 'just work' when restoring from an old backup. I was gifted an M1 Mac Mini (thanks, girlfriend!) and tried to set it up with a backup from my Macbook Air. While some things worked, other things went horribly wrong. And going through the process of resetting an M1 Mac product is &lt;a href="https://www.forbes.com/sites/ewanspence/2020/11/19/apple-macbook-pro-macbook-air-macos-11-big-sur-restore-revive-bricked-failure-reset-fix/?sh=21416db35cef"&gt;a pain¹&lt;/a&gt; &lt;a href="https://appleinsider.com/articles/20/11/23/apple-provides-instructions-to-erase-and-restore-unresponsive-m1-macs"&gt;in the²&lt;/a&gt; &lt;a href="https://support.apple.com/en-gb/guide/apple-configurator-2/apdd5f3c75ad/mac"&gt;ass³&lt;/a&gt;, so I'm attempting to save you the headache.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;But I restored from a backup and mine works fine!&lt;/strong&gt;&lt;br&gt;
Great! Mine didn't.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Okay, so what do you recommend?&lt;/strong&gt;&lt;br&gt;
Start from scratch. Yeah, I know. It's not fun. But it doesn't have to be entirely terrible!&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Prerequisites
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://code.visualstudio.com/docs/editor/settings-sync"&gt;Enable Settings Sync in Visual Studio Code&lt;/a&gt; and sync your settings from your current machine&lt;/li&gt;
&lt;li&gt;Save your &lt;code&gt;.zshrc&lt;/code&gt; in a Github Gist or something of the sort.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Visual Studio Code
&lt;/h1&gt;

&lt;p&gt;Once you've got your settings from VS Code on your existing machine synced up, &lt;a href="https://code.visualstudio.com"&gt;install VS Code&lt;/a&gt; on your new machine, enable Settings Sync, and...sync your settings. Easy. All of your extensions will get installed, your settings will be synced, and you'll be set. If you were using a custom font (Fira Code, Dank.sh, Monoid, whatever floats your boat) go and install that. Done. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; Visual Studio Code Insiders just released a version compatible with M1 Macs! Link: &lt;a href="https://code.visualstudio.com/insiders/"&gt;VS Code ARM64&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  iTerm
&lt;/h1&gt;

&lt;p&gt;Once you install &lt;a href="https://iterm2.com/"&gt;iTerm 2&lt;/a&gt;, you'll probably want to install Homebrew, Oh My ZSH!, NVM and whatever else. Before doing &lt;em&gt;anything&lt;/em&gt;, go to your Applications folder, right-click on iTerm, click 'Get Info', and check the 'Open using Rosetta' option. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--68CWuP_q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/gSFphht/Screen-Shot-2020-12-14-at-5-24-03-AM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--68CWuP_q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/gSFphht/Screen-Shot-2020-12-14-at-5-24-03-AM.png" alt="Open iTerm using Rosetta"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before I did this, I was getting a bunch of undecipherable errors from various command line tools because (presumably) they have compatibility issues with the M1 chip. There are alternative solutions, but I found this to be the easiest to implement and the most out-of-sight-out-of-mind solution. Check the option and don't worry about it. From there you should be able to install all your shell integrations and command line tools with no problem. I was able to install Homebrew and some formulas, NVM, Python 3, and &lt;a href="https://github.com/guarinogabriel/mac-cli"&gt;Mac CLI&lt;/a&gt; with no issues.&lt;/p&gt;

&lt;p&gt;Create or update your &lt;code&gt;.zshrc&lt;/code&gt; file with your existing configuration which you should have uploaded to a Github Gist, and you're set.&lt;/p&gt;

&lt;p&gt;Or. At least I was set. 😅 Good luck!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>vscode</category>
    </item>
    <item>
      <title>How I Dealt With Imposter Syndrome</title>
      <dc:creator>Nitish Dayal</dc:creator>
      <pubDate>Tue, 08 Dec 2020 17:43:24 +0000</pubDate>
      <link>https://dev.to/nitishdayal/how-i-dealt-with-imposter-syndrome-5bp2</link>
      <guid>https://dev.to/nitishdayal/how-i-dealt-with-imposter-syndrome-5bp2</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; This post will be inevitably anecdotal, will probably be all over the place (I haven't written anything in years), and will most likely ooze with survivorship bias. If it feels like the things I talk about don't apply to you, that's fine. Everyone's journey is different. I wanted to share this in the hopes that even one person would get something out of it.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After one year of unemployment, I &lt;a href="https://twitter.com/nitish_dayal/status/1335028080126033920?s=20"&gt;finally landed a job&lt;/a&gt; as a frontend engineer. 😄 In this post I'll share a little about who I am, what led to this one year gap in my employment, and what I did to get back into the industry.&lt;/p&gt;

&lt;p&gt;If you're exclusively interested in learning about how I approached the application and interview process, just skip to the last two parts. The rest of the post is about who I am and how I dealt with some particularly crippling imposter syndrome.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Who I Am&lt;/li&gt;
&lt;li&gt;The One Year Gap&lt;/li&gt;
&lt;li&gt;Applying and Interviewing&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Who Am I (professionally) &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Basics:&lt;/strong&gt; 30 year old Indian guy, raised in the US since I was 7. Another Javascript person, mostly client-side.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Education:&lt;/strong&gt; High school diploma, dropped out of a bunch of colleges, 2015 coding bootcamp grad (name doesn't matter, they're basically all the same).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prior experience:&lt;/strong&gt; 10 years in retail, sales, and banking. Was fairly successful; I was able to survive off of my income and support myself, but the job wasn't particularly rewarding and upward mobility didn't seem to alleviate that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Industry experience:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;10mos as an Assistant Instructor at aforementioned coding bootcamp&lt;/li&gt;
&lt;li&gt;4mos with a small start-up, helping them migrate from AngularJS to Angular (at the time, 2.0)&lt;/li&gt;
&lt;li&gt;2yrs 5mos at Amazon as a Web Development Engineer; 1 yr working on the retail side, 1yr 5mos on the API Gateway console team&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The One Year Gap &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;tldr; Left Amazon in September of 2019, spent next 6mos dealing with family stuff, then entered the job market in a world of COVID and imposter syndrome, wasted a bunch of time telling myself I sucked, started another bootcamp, and didn't apply for a job until November.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I left Amazon in September of 2019. I wasn't enjoying the work, after switching teams I found it very difficult to gain any form of mentorship, and I found myself constantly butting heads with management. It reached a point where going into the office had become the primary source of stress in my life. While it would have been better to seek out employment before leaving my job, I don't regret the way I did things. I was miserable and I did what I had to do for my mental health.&lt;/p&gt;

&lt;p&gt;Shortly after leaving, there was a medical-related family emergency that came up, and I chose to prioritize that over getting back to work. It was March of 2020 when things finally settled down and I was able to focus on looking for a job. Not only was COVID-19 in full effect, 6 months had passed since I had actively participated in the web development world. Given the pace at which that world moves, I felt very out of touch. Browsing through Twitter fueled my imposter syndrome; I had no clue what the hell anyone was talking about. "Are my skills even relevant any more? Do I need to learn &lt;code&gt;&amp;lt;insert-trending-library/framework/technology/language-here&amp;gt;&lt;/code&gt;? Should I &lt;strong&gt;~just build stuff&lt;/strong&gt;?" I had no clue where to start.&lt;/p&gt;

&lt;p&gt;I ended up splitting my time between going through Web Development fundamentals, Javascript fundamentals, and learning various trending libraries (Vue, Svelte, whatever else). No matter what I did, I couldn't help but feel like I was wasting time and not learning skills that would help me find employment. Going through the fundamentals felt tedious; I knew all of the subjects covered. I already had a career in this field. I &lt;em&gt;should be qualified&lt;/em&gt;. But when I would look at job descriptions, I would think to myself 'no, no, I need to learn more before I can apply.' I was just talking myself out of applying. Between September 2019 and August 2020, I submitted 0 job applications. I would find jobs, read the job description, tell myself I wasn't qualified, not apply, and then go do some more beginner courses. &lt;strong&gt;I am not a beginner.&lt;/strong&gt; To be clear, there is nothing wrong with being a beginner. I'm just not one. So, while an argument could be made that going through these courses cemented my understanding and built a strong foundation, it wasn't a particularly good use of my time. I should have either learned new topics that I wasn't familiar with, or focused on building projects to add to a portfolio.&lt;/p&gt;

&lt;p&gt;I eventually convinced myself that the best thing I could do for myself was to immerse myself in programming and web development again. While I might not have the nicest things to say about bootcamps, I acknowledge that they are very good for one thing: providing an environment conducive to learning made up of highly motivated individuals. So I signed up for another bootcamp, hoping that it would help me build some confidence regarding my knowledge and skills, and that I would be able to create projects to add to my portfolio. And the bootcamp experience did just that. I found that I was familiar with all the topics discussed. I had done this stuff before for a profession. I can do it again. &lt;/p&gt;

&lt;h2&gt;
  
  
  Applying and Interviewing &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;How I learned about the opportunity:&lt;/strong&gt; I was talking with a friend of mine about my past experience at Amazon and why I left, and we got on the topic of what I was looking for in a team. After some discussion, he recommended I apply to the company he works for. He was close with one of the leads for the web development team, and he felt like my goals aligned with what the team was aiming to achieve.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The interview process:&lt;/strong&gt; After sending my resume to my friend, I was contacted by one of their internal recruiters for a 20 minute interview. This interview was a 'get to know you' interview. The recruiter asked me about my past experience, the gap in my employment history, my education, what I was looking for in a career, why I wanted to work at this company...I wasn't asked any technical questions. After a day, I was contacted again by the recruiter about setting up a 45-min interview with the Senior Director for Web Technologies. I asked the recruiter if this would be a technical interview, and they told me it would be a mix.&lt;/p&gt;

&lt;p&gt;This interview, again, started with the standard 'get to know you' questions. &lt;strong&gt;You should have consistent, practiced responses to these questions.&lt;/strong&gt; Having concise, rehearsed responses will help you sound confident in the interview and will help the conversation move forward quickly. It's okay if you have a few 'um's and 'uh's in your answer, but you want to avoid long silences while you try to formulate a response. Think about common non-technical interview questions ("Tell me why you want to work here", for example), or find a list of them online, and prepare answers for them. Practice saying those answers out loud.&lt;/p&gt;

&lt;p&gt;After those questions, we got to the technical part of the interview. Given that this interview was over the phone, it was more of a knowledge check than anything else. Could I confidently speak about scope in Javascript? Did I understand hoisting? Did I understand what the purpose of a Promise is? How would I create a two-column layout using CSS? How would I tell a browser that a cached asset is no longer valid? I wasn't asked to write any code, but I had to be able to speak confidently about topics that were relevant to web development fundamentals. &lt;strong&gt;Being able to write code is obviously important, but it's arguably more important to be able to &lt;em&gt;talk&lt;/em&gt; about your code.&lt;/strong&gt; In a team environment, communication is key. Being able to talk through how you approach a problem is just as important as writing out your solution. At the end of this interview, I made sure to ask what the next steps would look like. If there's only one question I urge you to ask when your interviewer says "do you have any questions for me?", I think this is the one. Regardless of however many books and articles people can release on the topic, the tech interview is shrouded in mystery because it changes from one company to the next. Don't be afraid to ask what comes next. You want to be able to prepare for success, and hopefully the company you're interviewing with wants you to succeed.&lt;/p&gt;

&lt;p&gt;The final interview was to be a 3hr 'remote onsite'. Basically, I was to sit in front of a webcam and go through the interview gamut with a bunch of seniors, managers, leads, etc. I knew this would be purely technical, but I had no idea what kind of questions would be asked of me. Would I be asked about data structures and algorithms? Would it be more relevant to web development?&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--QHr0wKQu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/881417358841069568/mtVWiJGd_normal.jpg" alt="Nitish Dayal profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Nitish Dayal
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @nitish_dayal
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P4t6ys1m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      If they ask a bunch of Javascript stuff, I'll be fine. If someone asks me to implement and traverse a BST, I might just respond with 'google it'.
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      14:31 PM - 02 Dec 2020
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1334143180241977348" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-reply-action.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1334143180241977348" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-retweet-action.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      0
      &lt;a href="https://twitter.com/intent/like?tweet_id=1334143180241977348" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-like-action.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
      1
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;p&gt;I had no clue. So I reached out to some current employees and members of the web development team on LinkedIn and asked them. There's no harm in doing this. It takes very little effort, and the worst that could happen is that you don't get a response, in which case you'd be exactly where you started. No big deal. Thankfully, someone did respond to me and confirmed that the interview questions would be centered around web development, with some questions around architecture, client/server best practices, and working in a team environment.&lt;/p&gt;

&lt;p&gt;Every person I spoke to during this interview started with the same 'get to know you' questions. Again, practice your responses to these. Get your answers down so you can get to the rest of the interview and show off what you know. The technical questions were in line with what I was told, and for the most part I wasn't caught off guard, but there were a few times I was stumped.&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--QHr0wKQu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/881417358841069568/mtVWiJGd_normal.jpg" alt="Nitish Dayal profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Nitish Dayal
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @nitish_dayal
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P4t6ys1m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      Crushed first two parts of the interview, was feeling great. Next interviewer is Chief Engineering Officer. ‘How would you implement a micro front-end? What would the architecture look like?’&lt;br&gt;&lt;br&gt;Shit.
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      00:24 AM - 03 Dec 2020
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1334292284976685057" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-reply-action.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1334292284976685057" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-retweet-action.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      0
      &lt;a href="https://twitter.com/intent/like?tweet_id=1334292284976685057" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-like-action.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
      3
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;p&gt;In those moments, I made sure to maintain some level of confidence, and tried to talk through my thoughts and how I was trying to solve the problem. Having all the right answers is great, but when you're on the job, there will inevitably be a problem that you don't know how to solve. &lt;strong&gt;What's more important than getting the right answer to every question is to be able to explain your thought process, and walk through your approach to problem-solving.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I was contacted 3 days after the interview and was presented with an offer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Lots of words. What I hope you can take away from this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Don't doubt your skills. If you do, ask yourself what you need to do to alleviate those doubts, and do it.&lt;/li&gt;
&lt;li&gt;Don't listen to all the Twitter hype or buy into the FOMO. Obviously this is easier said than done, but do what you can to turn away and just focus on yourself. That time scrolling through Twitter and reading about the hot new thing Thoughtleader X is selling to their 40k followers is probably better spent just...doing stuff.&lt;/li&gt;
&lt;li&gt;A gap in your employment experience is fine. When asked about mine, I tried to explain it as transparently as I could. I wasn't shy or ashamed of it. It's just a part of my experience.&lt;/li&gt;
&lt;li&gt;If you're invited to interview with a company, do what you can to learn about their interview process. Reach out to people who work there with the title that you're applying for, or work at the department you're applying to, and ask them what you can expect. Search for '&lt;code&gt;&amp;lt;company name&amp;gt;&lt;/code&gt; interview process &lt;code&gt;&amp;lt;job title&amp;gt;&lt;/code&gt;' or something along those lines, and see if anything relevant comes up. The more surprises you can eliminate, the better your chances are.&lt;/li&gt;
&lt;li&gt;It's okay if you don't have an answer to a question off the top of your head. Talk through it. Ask questions to gain more insight into the problem you're being asked to solve. Talk about how you would approach solving it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I was very fortunate that the first place I applied to was willing to hire me, but I can't help but wonder how much sooner I could have had a job had I listened to same advice I listed above. I hope this information motivates at least one other person to feel confident about themselves, and to go out there and apply.&lt;/p&gt;

&lt;p&gt;Thanks for taking the time to read! 😄 If you'd like to connect, you can find me on &lt;a href="https://twitter.com/nitish_dayal"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>interview</category>
      <category>javascript</category>
      <category>career</category>
    </item>
    <item>
      <title>Stages of Learning Webpack, Pt. 3 - SourceMaps, Loaders, &amp; Plugins</title>
      <dc:creator>Nitish Dayal</dc:creator>
      <pubDate>Sun, 18 Jun 2017 05:59:58 +0000</pubDate>
      <link>https://dev.to/nitishdayal/stages-of-learning-webpack-pt-3---sourcemaps-loaders--plugins</link>
      <guid>https://dev.to/nitishdayal/stages-of-learning-webpack-pt-3---sourcemaps-loaders--plugins</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;This article is a continuation of the &lt;a href="https://dev.to/nitishdayal/stages-of-learning-webpack"&gt;Stages of Learning Webpack&lt;/a&gt; series. The repository containing the source code has been updated since the last article to include the latest versions of all dependencies as well as some configuration improvements (read: I might've made a lot of goofs the first time around).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/nitishdayal/webpack-stages-example"&gt;Github Repo&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2, Cont.
&lt;/h3&gt;

&lt;p&gt;At some point, you'll need to debug your application. Most modern browsers provide intuitive &lt;em&gt;developer tools&lt;/em&gt; which can assist in debugging and optimizing your application.&lt;/p&gt;

&lt;p&gt;In your text editor, change the first line in &lt;code&gt;src/app/sayHello.js&lt;/code&gt; to the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;alet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Hello &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We've placed an intentional error in our application by misspelling &lt;code&gt;alert&lt;/code&gt; as &lt;code&gt;alet&lt;/code&gt;. From the command line, run &lt;code&gt;npm run build&lt;/code&gt;/&lt;code&gt;yarn build&lt;/code&gt;. The build should still succeed; Webpack is not responsible for maintaining the accuracy of our JavaScript code. Open the &lt;code&gt;index.html&lt;/code&gt; file in your browser and open your browser's developer tools. There will be an error message along the lines of &lt;code&gt;ReferenceError: alet is not defined&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Clicking on the filename to the right of the error message will navigate us to the line &amp;amp; column of the file in which the error occurred. Since our &lt;code&gt;index.html&lt;/code&gt; file is using the generated Webpack bundle to load our JavaScript code, we'll be pointed to the line in the generated Webpack bundle at which the error occurred. From there, it's up to us to work our way backwards from the point of error in the &lt;em&gt;bundle&lt;/em&gt; to the point of error in our actual source code.&lt;/p&gt;

&lt;p&gt;If that's what's involved in debugging, then I'm not debugging any more. There must be an easier way. We can do better. &lt;strong&gt;&lt;em&gt;We have the technology.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Branch: sourceMaps&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let's start by looking at the differences between this branch (sourceMaps) and the previous (init):&lt;/p&gt;




&lt;h4&gt;
  
  
  Changes to &lt;code&gt;webpack.config.js&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;We've added a new key to the Webpack configuration object; the &lt;code&gt;devtool&lt;/code&gt; key. The value associated with this key depends on the value of the &lt;em&gt;argument&lt;/em&gt; &lt;code&gt;env&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;devtool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;production&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;source-map&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cheap-eval-source-map&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./src/index.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./build/bundle.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;extensions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can rewrite the file in ES5 as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;devtool&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;production&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;devtool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;source-map&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;devtool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cheap-eval-source-map&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;devtool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;devtool&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./src/index.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./build/bundle.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;extensions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First, we declare a variable &lt;code&gt;devtool&lt;/code&gt;. Then, &lt;em&gt;if&lt;/em&gt; the &lt;code&gt;env&lt;/code&gt; argument isn't &lt;code&gt;undefined&lt;/code&gt; &lt;strong&gt;and&lt;/strong&gt; &lt;code&gt;env&lt;/code&gt; is an object with a key/value pair &lt;code&gt;{ production: true }&lt;/code&gt;, then define the value of &lt;code&gt;devtool&lt;/code&gt; as a string &lt;code&gt;"source-map"&lt;/code&gt;. Otherwise, define &lt;code&gt;devtool&lt;/code&gt; as &lt;code&gt;"cheap-eval-source-map"&lt;/code&gt;. The meaning associated with these values will be explained later; for now, I want to be clear that all we've done is create a variable, and define that variable as a string. The value of that string is dependent on a conditional statement (the &lt;em&gt;if/else&lt;/em&gt; block).&lt;/p&gt;

&lt;p&gt;Finally, we return an object with a set of key/value pairs that Webpack can use to create our bundle. The &lt;code&gt;entry&lt;/code&gt;, &lt;code&gt;output&lt;/code&gt;, and &lt;code&gt;resolve&lt;/code&gt; key/value pairs have been carried over from the &lt;code&gt;init&lt;/code&gt; branch.&lt;/p&gt;

&lt;h4&gt;
  
  
  Changes to &lt;code&gt;package.json&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;We've updated the &lt;code&gt;scripts&lt;/code&gt; section of the &lt;code&gt;package.json&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/*...*/&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;scripts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;build&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;webpack&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="cm"&gt;/*...*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;After:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/*...*/&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;scripts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dev&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;webpack&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;prod&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;webpack --env.production&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="cm"&gt;/*...*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The name of the command which calls Webpack has been changed from &lt;code&gt;build&lt;/code&gt; to &lt;code&gt;dev&lt;/code&gt;. The naming convention implies that this will create a &lt;em&gt;development&lt;/em&gt; version of the bundle, and this is true. We're not having Webpack run any sort of optimization when it creates the bundle. Our configuration just says 'take this entry file (&lt;code&gt;src/index.js&lt;/code&gt;) and every file it imports, bundle them all together, and output that bundle as a file (&lt;code&gt;./build/bundle.js&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;There is also a new key, &lt;code&gt;prod&lt;/code&gt;. Again, the naming convention implies that this will create a &lt;em&gt;production&lt;/em&gt; version of the bundle. It doesn't. Yet. But it will! Right now, the only difference between the &lt;code&gt;prod&lt;/code&gt; script and the &lt;code&gt;dev&lt;/code&gt; script is that we're now passing an argument to the exported function in &lt;code&gt;webpack.config.js&lt;/code&gt; as the &lt;code&gt;env&lt;/code&gt; argument, which the function then uses to create and return the Webpack configuration object. To see this in action, you can place a &lt;code&gt;console.log(env)&lt;/code&gt; statement inside the function exported from &lt;code&gt;webpack.config.js&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// webpack.config.js&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;devtool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;production&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;source-map&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cheap-eval-source-map&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./src/index.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./build/bundle.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;extensions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the command line, run the command &lt;code&gt;npm run dev&lt;/code&gt;/&lt;code&gt;yarn dev&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; webpack

undefined
Hash: 9d81a1b766e4629aec0c
Version: webpack 2.6.1
Time: 82ms
            Asset     Size  Chunks             Chunk Names
./build/bundle.js  5.75 kB       0  &lt;span class="o"&gt;[&lt;/span&gt;emitted]  main
   &lt;span class="o"&gt;[&lt;/span&gt;0] ./src/app/sayHello.js 233 bytes &lt;span class="o"&gt;{&lt;/span&gt;0&lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;built]
   &lt;span class="o"&gt;[&lt;/span&gt;1] ./src/index.js 453 bytes &lt;span class="o"&gt;{&lt;/span&gt;0&lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;built]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That &lt;code&gt;undefined&lt;/code&gt; right after &lt;code&gt;&amp;gt; webpack&lt;/code&gt; is our &lt;code&gt;console.log(env)&lt;/code&gt; statement. It's undefined because we didn't pass any additional arguments to Webpack in our &lt;code&gt;dev&lt;/code&gt; command. Now, let's run the &lt;code&gt;npm run prod&lt;/code&gt;/&lt;code&gt;yarn prod&lt;/code&gt; command from the command line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; webpack &lt;span class="nt"&gt;--env&lt;/span&gt;.production

&lt;span class="o"&gt;{&lt;/span&gt; production: &lt;span class="nb"&gt;true&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
Hash: cbc8e27e9f167ab0bc36
Version: webpack 2.6.1
Time: 90ms
                Asset     Size  Chunks             Chunk Names
    ./build/bundle.js  3.79 kB       0  &lt;span class="o"&gt;[&lt;/span&gt;emitted]  main
./build/bundle.js.map  3.81 kB       0  &lt;span class="o"&gt;[&lt;/span&gt;emitted]  main
   &lt;span class="o"&gt;[&lt;/span&gt;0] ./src/app/sayHello.js 233 bytes &lt;span class="o"&gt;{&lt;/span&gt;0&lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;built]
   &lt;span class="o"&gt;[&lt;/span&gt;1] ./src/index.js 453 bytes &lt;span class="o"&gt;{&lt;/span&gt;0&lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;built]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of seeing &lt;code&gt;undefined&lt;/code&gt;, we're seeing an object with one key/value pair &lt;code&gt;{ production: true }&lt;/code&gt;. These values match up with the conditional statement in our Webpack configuration; our conditional statement ensures that the argument &lt;code&gt;env&lt;/code&gt; isn't undefined, and that it is an object with a key/value pair &lt;code&gt;{ production: true }&lt;/code&gt;. You might have noticed that the generated bundles from the commands are different as well. The bundle generated with the &lt;code&gt;dev&lt;/code&gt; command is larger than bundle generated by &lt;code&gt;prod&lt;/code&gt;, however the &lt;code&gt;prod&lt;/code&gt; command generated an additional file &lt;code&gt;bundle.js.map&lt;/code&gt;.&lt;/p&gt;




&lt;p&gt;Open the file &lt;code&gt;src/app/sayHello.js&lt;/code&gt;. Since this is a different branch of the Git repository, the error we previously placed in this file might not carry over if the changes were made in the &lt;code&gt;init&lt;/code&gt; branch. If that's the case, change the first line so that the &lt;code&gt;alert&lt;/code&gt; call is misspelled as &lt;code&gt;alet&lt;/code&gt;. Save your changes, then run &lt;code&gt;npm run dev/yarn dev&lt;/code&gt; from the command line again. Open &lt;code&gt;index.html&lt;/code&gt; in your browser, then open the browser's devtools. You should have an error in the console stating &lt;code&gt;alet is not defined&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If the console claims that this error is being generated in the &lt;code&gt;index.html&lt;/code&gt; file, refresh the page. You should see something along the lines of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ReferenceError: alet is not defined          sayHello.js?7eb0:1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Clicking on this error should take you to the line &amp;amp; file in which the error occurred, but you'll notice that the entire line is highlighted as an error. In this case, that's not entirely inaccurate. But let's say we change the &lt;code&gt;src/app/sayHello.js&lt;/code&gt; file around again. This time, we'll change the reference to &lt;code&gt;name&lt;/code&gt; inside of the &lt;code&gt;alert&lt;/code&gt; call to be &lt;code&gt;namen&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Hello &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;namen&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;donut&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I WANT YOUR DONUTS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/**
 * Same code, ES5 style:
 * 
 * function sayName(name){
 *    return alert('Hello ' + name);
 * }
 * 
 * export default sayName;
 * 
 */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;npm run dev/yarn dev&lt;/code&gt; from the command line again, and refresh the &lt;code&gt;index.html&lt;/code&gt; file that's open in your browser. The console in your devtools should display a similar error message; &lt;code&gt;namen is not defined&lt;/code&gt;. Clicking on the error message will, again, take us to the line in which the error occurred.&lt;/p&gt;

&lt;p&gt;Now, run &lt;code&gt;npm run prod&lt;/code&gt;/&lt;code&gt;yarn prod&lt;/code&gt; from the command line, and refresh the &lt;code&gt;index.html&lt;/code&gt; file in your browser. Open your devtools and look at the error in your console, the filename is now just &lt;code&gt;sayHello.js&lt;/code&gt;. Clicking on the error navigates us not only to the file &amp;amp; line in which the error occurred, but also the column in which it occurred. The error underline is more specific as well; it begins at &lt;code&gt;namen&lt;/code&gt; as opposed to underlining the whole first line.&lt;/p&gt;

&lt;p&gt;And that's the difference between the two commands; the accuracy of the source maps they generate. The reason we use a less accurate version of source maps for development purposes is because they are faster to generate than to have Webpack generate full source map files each time we create a build. You can learn about the different options for source mapping with Webpack here: &lt;a href="https://webpack.js.org/configuration/devtool/"&gt;Webpack Devtool Configuration.&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Branch: loader&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Notice that the generated bundles maintain all ES2015 syntax used in the source files; &lt;code&gt;let&lt;/code&gt; &amp;amp; &lt;code&gt;const&lt;/code&gt;, arrow functions, newer object literal syntax, etc. If we tried to run our application in an older browser which didn't have support for these features, the application would fail. This is where we'd usually take advantage of a &lt;em&gt;transpiler&lt;/em&gt; such as Babel, TypeScript, CoffeeScript, etc. to run through our code and translate it to a version with better cross-browser support. The &lt;em&gt;loader&lt;/em&gt; branch covers how to integrate TypeScript into our Webpack build process in order to transpile our application code down to ES3 syntax. Note that we don't introduce any TypeScript-specific features; I even leave the files as .js files. We'll be using TypeScript as an ESNext --&amp;gt; ES3 transpiler.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Strap in folks; this one's gonna be bumpy.&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Dependencies
&lt;/h4&gt;

&lt;p&gt;Looking at the &lt;code&gt;package.json&lt;/code&gt; file, we've added two new &lt;em&gt;developer dependencies&lt;/em&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TypeScript: As stated earlier, we'll use TypeScript as our transpiler.&lt;/li&gt;
&lt;li&gt;TS-Loader: Loaders allow Webpack to understand &lt;em&gt;more&lt;/em&gt; than JavaScript. In this case, TS-Loader allows Webpack to use TypeScript to load TypeScript (and JavaScript) files and transpile them based on your TypeScript configuration before generating a browser-friendly bundle.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To install these dependencies, run &lt;code&gt;npm install&lt;/code&gt; from the command line. NPM should read the &lt;code&gt;package.json&lt;/code&gt; file and install the dependencies as listed. In general, to install additional developer dependencies, you can run &lt;code&gt;npm i -D &amp;lt;package-name&amp;gt;&lt;/code&gt;, where &lt;code&gt;&amp;lt;package-name&amp;gt;&lt;/code&gt; is the package you want to install, ie: &lt;code&gt;npm i -D typescript&lt;/code&gt;. The -D flag tells NPM to save the installed package as a developer dependency.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;prod&lt;/code&gt; command has been updated as well; it now includes the flag &lt;code&gt;-p&lt;/code&gt;. The &lt;code&gt;-p&lt;/code&gt; flag is an option that can be provided to the Webpack CLI (command line interface, the tool that NPM calls on when a &lt;code&gt;script&lt;/code&gt; in the &lt;code&gt;package.json&lt;/code&gt; file uses &lt;code&gt;webpack&lt;/code&gt;) which provides optimizations for a production environment. We'll take a deeper look at this shortly.&lt;/p&gt;

&lt;h4&gt;
  
  
  TypeScript Configuration
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;tsconfig.json&lt;/code&gt; file provides information for TypeScript to utilize when transpiling our code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;compilerOptions&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;allowJs&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;module&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;es2015&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;target&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;es3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sourceMap&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;strict&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;include&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./src/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;exclude&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;node_modules/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./build/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This configuration object tells TypeScript a few things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TypeScript is generally used to transpile TypeScript files (&lt;code&gt;.ts&lt;/code&gt;) into JavaScript. By setting &lt;code&gt;allowJs&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt;, we're allowing TypeScript to transpile .js files.&lt;/li&gt;
&lt;li&gt;TypeScript is capable of transpiling JavaScript to work with a variety of module systems. We're telling TypeScript to use the ES2015 module system because Webpack is able to apply some pretty nifty optimizations when applications are created using this variation.&lt;/li&gt;
&lt;li&gt;We can target most JavaScript versions from ES3 to ESNext. Given that we're aiming for &lt;em&gt;BETTER&lt;/em&gt; browser support, not horrendously worse, we go with ES3.&lt;/li&gt;
&lt;li&gt;Generate source maps for each transpiled file.&lt;/li&gt;
&lt;li&gt;Use all the &lt;code&gt;strict&lt;/code&gt; type-checking features that TypeScript offers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Webpack Configuration Updates
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;devtool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;production&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;source-map&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;inline-source-map&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="cm"&gt;/* ... */&lt;/span&gt;
  &lt;span class="nx"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="sr"&gt;js&lt;/span&gt;&lt;span class="se"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;x&lt;/span&gt;&lt;span class="se"&gt;)?&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;loader&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ts-loader&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;transpileOnly&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;entryFileIsJs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We've introduced a new key to the Webpack configuration object; &lt;code&gt;module&lt;/code&gt;. The &lt;code&gt;module&lt;/code&gt; section provides information to Webpack regarding how to work with certain files that are utilized throughout the application. We've provided one rule, which can be read as such:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When Webpack comes across a file ending in &lt;code&gt;.js&lt;/code&gt; or &lt;code&gt;.jsx&lt;/code&gt;, it will first pass the files to TS-Loader before generating a the requested bundle. TS-Loader is responsible only for transpiling the application; we are not using any of the type-checking features provided by TypeScript.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The type of source map used for development environments has been changed from "cheap-eval-source-map" to "inline-source-map". The differences between these two options are covered in the Webpack documentation:  here: &lt;a href="https://webpack.js.org/configuration/devtool/"&gt;Webpack Devtool Configuration.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run &lt;code&gt;npm run dev&lt;/code&gt;/&lt;code&gt;yarn dev&lt;/code&gt; from the command line and open the &lt;code&gt;index.html&lt;/code&gt; file in your browser. Everything should work as expected. Look at lines 73-105 in the generated bundle:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="cm"&gt;/* unused harmony export donut */&lt;/span&gt;
&lt;span class="cm"&gt;/* harmony default export */&lt;/span&gt; &lt;span class="nx"&gt;__webpack_exports__&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;});;&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;donut&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I WANT YOUR DONUTS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="cm"&gt;/**
 * Same code, ES5 style:
 *
 * function sayName(name){
 *    return alert('Hello ' + name);
 * }
 *
 * export default sayName;
 *
 */&lt;/span&gt;


&lt;span class="cm"&gt;/***/&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
&lt;span class="cm"&gt;/* 1 */&lt;/span&gt;
&lt;span class="cm"&gt;/***/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;__webpack_exports__&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;__webpack_require__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;defineProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__webpack_exports__&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;__esModule&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="cm"&gt;/* harmony import */&lt;/span&gt; &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;__WEBPACK_IMPORTED_MODULE_0__app_sayHello__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;__webpack_require__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Import whatever the default export is from /app/sayHello&lt;/span&gt;
&lt;span class="c1"&gt;// and refer to it in this file as 'Hello'&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Nitish&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Reference to the &amp;lt;div id="root"&amp;gt; element in&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Call the function that was imported from /app/sayHello, passing in&lt;/span&gt;
&lt;span class="c1"&gt;// `const name` that was created on line 5.&lt;/span&gt;
&lt;span class="nx"&gt;__webpack_require__&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__WEBPACK_IMPORTED_MODULE_0__app_sayHello__&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="cm"&gt;/* default */&lt;/span&gt;&lt;span class="p"&gt;])(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Helllloooo &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All &lt;code&gt;const&lt;/code&gt; and &lt;code&gt;let&lt;/code&gt; declarations have been converted to &lt;code&gt;var&lt;/code&gt;. The template strings used in the alert message and for &lt;code&gt;root.textContent&lt;/code&gt; have been replaced with string concatenation. Our bundle was created using the &lt;em&gt;transpiled&lt;/em&gt; code generated by TypeScript.&lt;/p&gt;

&lt;p&gt;If we remember from earlier, &lt;code&gt;src/app/sayHello.js&lt;/code&gt; exports two items; a function as a &lt;em&gt;default export&lt;/em&gt;, and a constant &lt;code&gt;donut&lt;/code&gt; as a &lt;em&gt;named export&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Hello &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;donut&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I WANT YOUR DONUTS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second export isn't used anywhere in the application, but it's still included in the bundle. However, if we run &lt;code&gt;npm run prod&lt;/code&gt;/&lt;code&gt;yarn prod&lt;/code&gt; and take a look at our bundle then...&lt;/p&gt;

&lt;p&gt;It's a hot mess! Here's a (nicer, formatted) look at the bundle:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;o&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;i&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;l&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;o&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;l&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;o&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
      &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;defineProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;configurable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;enumerable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;__esModule&lt;/span&gt;
      &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;o&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hasOwnProperty&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;})([&lt;/span&gt;
  &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;defineProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;__esModule&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;o&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Nitish&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;o&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Helllloooo Nitish!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;span class="c1"&gt;//# sourceMappingURL=bundle.js.map&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's still a hot mess! There isn't much of a need to manually parse through this; it's 38 lines of IIFE goodness, so it's doable, but there's no obligation and it won't assist with the rest of this guide. What I'm trying to show here is that the generated &lt;em&gt;production&lt;/em&gt; bundle has no reference to the line &lt;code&gt;const donut = "I WANT YOUR DONUTS!";&lt;/code&gt;. It's completely dropped from the bundle. Along with the minification, uglification, and handful of other out-of-the-box production optimizations Webpack is capable of implementing when provided the &lt;code&gt;-p&lt;/code&gt; flag, &lt;strong&gt;tree-shaking&lt;/strong&gt; is part of that list. I didn't have to do anything to enable tree-shaking; it Just Works™.&lt;/p&gt;

&lt;p&gt;Excellent! We're transpiling our ES2015+ code down to ES3, removing any unused code along the way, and generating a production(ish)-quality bundle that can be loaded by most modern browsers with errors and warnings pointing back to our source code for simplified debugging.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Branch: plugin&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Plugins do exactly what they say on the tin; they plug into the build process to introduce extra functionality. In this example, we'll get introduced to &lt;a href="https://github.com/jantimon/html-webpack-plugin#configuration"&gt;HTMLWebpackPlugin&lt;/a&gt;, a plugin for generating HTML documents which can serve our Webpack bundles.&lt;/p&gt;

&lt;p&gt;As it stands, we created an HTML file which points to the expected bundle. In simple situations, a setup like this would work fine. As the application grows, the bundle could get split into more than one file, The filenames might be randomly generated, etc. If we were to try and manually maintain the list of files that need to be loaded into our HTML file...well, we're kind of back to square A, right? We'll use HTMLWebpackPlugin to automate the process of loading our bundles into our HTML document.&lt;/p&gt;

&lt;h4&gt;
  
  
  File Changes
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Introduced a new developer dependency to the &lt;code&gt;package.json&lt;/code&gt; file; &lt;code&gt;HTMLWebpackPlugin&lt;/code&gt;. Make sure to run &lt;code&gt;npm install&lt;/code&gt;/&lt;code&gt;yarn&lt;/code&gt; when you've switched to this branch to get the necessary dependencies.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;devDependencies&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;html-webpack-plugin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;^2.28.0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ts-loader&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;^2.1.0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;typescript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;^2.3.4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;webpack&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;^2.6.1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;index.html&lt;/code&gt; file no longer loads the &lt;code&gt;build/bundle.js&lt;/code&gt; file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;webpack.config.js&lt;/code&gt; has been updated to include a CommonJS style import statement (&lt;code&gt;const HTMLWebpackPlugin = require("html-webpack-plugin");&lt;/code&gt;) at the top of the file, and has a new section, &lt;code&gt;plugins&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="c1"&gt;//webpack.config.js&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;HTMLWebpackPlugin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;html-webpack-plugin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="cm"&gt;/*...*/&lt;/span&gt;
      &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;HTMLWebpackPlugin&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
          &lt;span class="na"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./build/index.html&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;inject&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;body&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./index.html&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="p"&gt;})&lt;/span&gt;
      &lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We're telling Webpack that we'll be using HTMLWebpackPlugin to generate an HTML file named &lt;code&gt;index.html&lt;/code&gt; inside of the &lt;code&gt;build&lt;/code&gt; folder. HTMLWebpackPlugin is to take any generated bundles and &lt;code&gt;inject&lt;/code&gt; them into the body of the HTML file in script tags. It will use the existing &lt;code&gt;index.html&lt;/code&gt; found in our application root as a template.&lt;/p&gt;

&lt;p&gt;If we call on &lt;code&gt;npm run dev&lt;/code&gt;/&lt;code&gt;yarn dev&lt;/code&gt; or &lt;code&gt;npm run prod&lt;/code&gt;/&lt;code&gt;yard prod&lt;/code&gt;, we should see something similar to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm run dev

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; webpack &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="nt"&gt;--env&lt;/span&gt;.production

ts-loader: Using typescript@2.3.4 and /Projects/dev_to/webpack_configs/example/tsconfig.json
Hash: 693b4a366ee89bdb9cde
Version: webpack 2.6.1
Time: 2233ms
             Asset       Size  Chunks             Chunk Names
 ./build/bundle.js    8.96 kB       0  &lt;span class="o"&gt;[&lt;/span&gt;emitted]  main
./build/index.html  352 bytes          &lt;span class="o"&gt;[&lt;/span&gt;emitted]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Based on the configuration provided, Webpack generated the requested bundle along with an &lt;code&gt;index.html&lt;/code&gt; file. The generated &lt;code&gt;index.html&lt;/code&gt; file looks very similar to our existing template, but carries a reference to the generated Webpack bundle inside of the document body.&lt;/p&gt;

&lt;p&gt;Open the &lt;strong&gt;new&lt;/strong&gt; index.html file (&lt;code&gt;./build/index.html&lt;/code&gt;) in your browser to make sure everything works as expected.&lt;/p&gt;

&lt;p&gt;Now stand back, rejoice in your work, and soak it all in. You're on your way to Webpacking the world, amigos. &lt;/p&gt;

</description>
      <category>webpack</category>
      <category>javascript</category>
      <category>typescript</category>
    </item>
    <item>
      <title>How do you practice programming?</title>
      <dc:creator>Nitish Dayal</dc:creator>
      <pubDate>Sun, 28 May 2017 18:38:07 +0000</pubDate>
      <link>https://dev.to/nitishdayal/how-do-you-practice-programming</link>
      <guid>https://dev.to/nitishdayal/how-do-you-practice-programming</guid>
      <description>&lt;p&gt;The idea came up when I was playing guitar. I play because I like to play, no professional aspirations or anything like that, but I still put in actual &lt;em&gt;practice&lt;/em&gt; hours. Practicing usually involves a collection of exercises that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Are fun to play.&lt;/li&gt;
&lt;li&gt;Build on different parts of fundamentals (picking techniques, arm/wrist movement, fretting hand positioning, etc.).&lt;/li&gt;
&lt;li&gt;Provide ways to measure progress.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And then I realized I have nothing like this when it comes to programming. I have a solid system for learning stuff (read the docs and headdesk until things work ðŸ‘ðŸ¾), but nothing when it comes to practicing. I've tried algorithm-challenge style books and websites, but frankly they're just stressful. Was hoping to hear from the Dev.to community regarding what options are available and works for y'all. ðŸ‘¨”ðŸ’»&lt;/p&gt;

&lt;p&gt;If more specific questions are preferred: How do you practice? How do you decide what to practice? Have you tried other methods? How is practicing different from learning? As in depth or as concise as you'd like, just happy to hear some ideas and recommendations.&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Stages of Learning Webpack, Pt. 2 - The Config</title>
      <dc:creator>Nitish Dayal</dc:creator>
      <pubDate>Mon, 22 May 2017 09:27:37 +0000</pubDate>
      <link>https://dev.to/nitishdayal/stages-of-learning-webpack-pt-2---the-config</link>
      <guid>https://dev.to/nitishdayal/stages-of-learning-webpack-pt-2---the-config</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;strong&gt;DISCLAIMER&lt;/strong&gt;: Webpack isn't the only option for module bundling. Module bundling isn't even the only option for solving the client-side module 'issue'. There's a whole lot of ways to do this stuff. I'm gonna take a crack at explaining some Webpack things because that's what I've been working with.  + my grammar isn't fantastic, and my vernacular is a mix of wannabe intellectual and obnoxious child. You've been warned.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This was supposed to go up last week, but things happened. ðŸ¤· The original draft was consumed by an unexpected system restart + me not saving my progress on the Dev.to platform, and on the second attempt I realized that trying to fit everything I mentioned at the end of my &lt;a href="https://dev.to/nitishdayal/stages-of-learning-webpack"&gt;first post&lt;/a&gt; would lead to either a post which wouldn't go deep enough to be valuable, or one which would cause information overload. Instead, I'm going to break that content up into multiple posts.&lt;/p&gt;

&lt;p&gt;The goal of &lt;strong&gt;this&lt;/strong&gt; post is to explain what &lt;a href="https://webpack.js.org" rel="noopener noreferrer"&gt;Webpack&lt;/a&gt; is by exploring the problem it attempts to solve, and to go over the basics of a Webpack configuration. The content will be targeted towards those who are new to the Webpack ecosystem. I don't know how much further above 'beginner' I would consider myself with Webpack, so if you're fairly seasoned read on regardless and provide feedback. ðŸ˜ƒ There are a &lt;em&gt;LOT&lt;/em&gt; of other posts similar to this one. I'm standing on the shoulders of slightly deprecated content.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction - The Problem With Client Side Modules
&lt;/h2&gt;

&lt;p&gt;As users have come to expect more from their applications, client-side JavaScript development has evolved to meet those expectations. We're at a point where placing all your code in one JavaScript file can become very unwelcoming, very quickly. Applications are developed by splitting a codebase into small, relevant chunks and placing those chunks in individual files. These files are called &lt;em&gt;JavaScript modules&lt;/em&gt;. When a piece of code in &lt;code&gt;fileA.js&lt;/code&gt; is needed in &lt;code&gt;fileB.js&lt;/code&gt;, that code can be imported into &lt;code&gt;fileB&lt;/code&gt; so long as it was exported in &lt;code&gt;fileA&lt;/code&gt;. In order to load these files into the browser, the approach when working with a more manageable number of files would be to add &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tags as necessary. This is feasible when working with a handful of files, but applications can quickly grow to a point where manually loading all the files would be very, very complicated. Not only would you be responsible for making sure that all the files were properly referenced in your root document (main &lt;code&gt;index.html&lt;/code&gt; file, whatever you call it), you would also have to manage the order in which they were loaded. I don't want to have to do that with 100+ files.&lt;/p&gt;

&lt;p&gt;For example, here is the directory structure from my boilerplate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  â”œâ”€â”€ LICENSE
  â”œâ”€â”€ README.md
  â”œâ”€â”€ TODO.todo
  â”œâ”€â”€ index.html
  â”œâ”€â”€ package.json
  â”œâ”€â”€ src/
  â”‚   â”œâ”€â”€ components/
  â”‚   â”‚   â”œâ”€â”€ containers/
  â”‚   â”‚   â”‚   â””â”€â”€ root.js &lt;span class="c"&gt;#1&lt;/span&gt;
  â”‚   â”‚   â”œâ”€â”€ displayItems.js &lt;span class="c"&gt;#2&lt;/span&gt;
  â”‚   â”‚   â”œâ”€â”€ hello.js &lt;span class="c"&gt;#3&lt;/span&gt;
  â”‚   â”‚   â”œâ”€â”€ page2.js &lt;span class="c"&gt;#4&lt;/span&gt;
  â”‚   â”‚   â””â”€â”€ styled/
  â”‚   â”‚       â”œâ”€â”€ elements/
  â”‚   â”‚       â”‚   â”œâ”€â”€ listwrapper.js &lt;span class="c"&gt;#5&lt;/span&gt;
  â”‚   â”‚       â”‚   â”œâ”€â”€ navwrapper.js &lt;span class="c"&gt;#6&lt;/span&gt;
  â”‚   â”‚       â”‚   â”œâ”€â”€ routerwrapper.js &lt;span class="c"&gt;#7&lt;/span&gt;
  â”‚   â”‚       â”‚   â””â”€â”€ styledlink.js &lt;span class="c"&gt;#8&lt;/span&gt;
  â”‚   â”‚       â””â”€â”€ index.js &lt;span class="c"&gt;#9&lt;/span&gt;
  â”‚   â”œâ”€â”€ main.js &lt;span class="c"&gt;#10&lt;/span&gt;
  â”‚   â”œâ”€â”€ routes/
  â”‚   â”‚   â””â”€â”€ index.js &lt;span class="c"&gt;#11&lt;/span&gt;
  â”‚   â””â”€â”€ store/
  â”‚       â””â”€â”€ listItems.js &lt;span class="c"&gt;#12&lt;/span&gt;
  â”œâ”€â”€ tslint.json
  â””â”€â”€ yarn.lock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Twelve JavaScript files for a &lt;strong&gt;boilerplate&lt;/strong&gt;; we're talking about a glorified 'Hello World'. Are these large files? Not at all. Take the files found under &lt;code&gt;src/components/styled/elements/&lt;/code&gt; &lt;a href="https://thepracticaldev.s3.amazonaws.com/i/ffzwgh10rw2c7pigx81j.png" rel="noopener noreferrer"&gt;(full size)&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fffzwgh10rw2c7pigx81j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fffzwgh10rw2c7pigx81j.png" title="Files under src/components/styled/elements/" alt="styled_components"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All of the files are under 25 lines of code. In fact, every file inside the &lt;code&gt;src/&lt;/code&gt; folder comes in under 50 lines. I didn't do this for the sake of line count, however. That's a beneficial side-effect of writing &lt;em&gt;modular&lt;/em&gt; code. I split my code this way because it gives me a codebase that's easier to maintain, easier to read, easier to navigate, and easier to debug. If I need to change the way my links appear, I know exactly where I need to go to make that change, and I know that once the change is made it will reflect anywhere that a link is created. The folder structure, while probably not all that visually appealing, is nice when programming because it's logical and organized; a styled link element is found under &lt;code&gt;styled/elements/styledlink&lt;/code&gt;. If there's an error or a bug (which there definitely will be), it's easy to trace the problem back to one file/module because they're split up with the intention of giving each module &lt;strong&gt;one&lt;/strong&gt; job. If something breaks, it's probably because I didn't tell someone how to do their job correctly, and it's usually easy to tell where the error is originating from. Once the error is addressed at the module level, I know it's going to be fixed anywhere else that code was reused.&lt;/p&gt;

&lt;h2&gt;
  
  
  Webpack as a Solution
&lt;/h2&gt;

&lt;p&gt;So how do we get this loaded into the browser &lt;em&gt;without&lt;/em&gt; dealing with &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag shenanigans? Webpack! Webpack will crawl through our app starting from the &lt;em&gt;application root&lt;/em&gt;, or the initial kick-off point (&lt;code&gt;src/main.js&lt;/code&gt;), following any &lt;code&gt;import&lt;/code&gt; statements until it has a complete &lt;em&gt;dependency graph&lt;/em&gt; of the application. Once it has that graph, it will create a bundled file (or files, depending on how you configure Webpack) which can be then be loaded into the browser from inside &lt;code&gt;index.html&lt;/code&gt;. VoilÃ ! In it's simplest use case, that's what Webpack does. It takes a bunch of JavaScript files and puts them together into one (or a few) files that are more manageable to work with when loading into the browser, while allowing you to maintain the modularity and separation that you like in your codebase.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"Wait a minute, guy. I've seen people use Webpack for CSS, pictures, videos...everything, and you're telling me it only does JS?"&lt;/em&gt; Yes! Out of the box, that's what Webpack is capable of understanding. However, at the beginning of my &lt;a href="https://dev.to/nitishdayal/stages-of-learning-webpack"&gt;first post&lt;/a&gt; I mentioned that Webpack is much more than &lt;strong&gt;just&lt;/strong&gt; a module bundler. With the right configuration settings, plugins, and loaders (more on this later), Webpack can be extended to understand most filetypes that front-end developers come across in order to bundle (and optimize) &lt;em&gt;ALL&lt;/em&gt; of your application assets. In most cases, my build process is entirely managed by Webpack &amp;amp; NPM scripts.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Basic Configuration
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Pre-requisites:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Node&lt;/li&gt;
&lt;li&gt;  NPM/Yarn - Installing dependencies, running scripts&lt;/li&gt;
&lt;li&gt;  Git - Branch, clone, commit&lt;/li&gt;
&lt;li&gt;  Patience - I may be too wordy for my own good sometimes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example code for this section can be found at: &lt;a href="https://github.com/nitishdayal/webpack-stages-example" rel="noopener noreferrer"&gt;github.com/nitishdayal/webpack-stages-example&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The rest of this post assumes you'll be following along by cloning the repo containing the example code. The repo is split into multiple branches that correspond with the upcoming sections.&lt;/p&gt;

&lt;p&gt;Initial file layout &amp;amp; directory structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; â”œâ”€â”€ index.html
 â”œâ”€â”€ package-lock.json
 â”œâ”€â”€ package.json
 â”œâ”€â”€ src
 â”‚   â”œâ”€â”€ app
 â”‚   â”‚   â””â”€â”€ sayHello.js
 â”‚   â””â”€â”€ index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The example provided has a few files worth noting:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;code&gt;index.html&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt; &lt;code&gt;src/app/sayHello.js&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt; &lt;code&gt;src/index.js&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's break down what's happening in the example:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;index.html&lt;/code&gt; is an HTML document with two key items:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  The &lt;code&gt;div&lt;/code&gt; HTMLElement with the id &lt;code&gt;root&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  The &lt;code&gt;script&lt;/code&gt; tag loading a file &lt;code&gt;./build/bundle.js&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;src/app/sayHello.js&lt;/code&gt; &lt;em&gt;exports&lt;/em&gt; two items.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  An anonymous function which takes one argument and returns a window alert with the message 'Hello ' + the provided argument as the &lt;strong&gt;default&lt;/strong&gt; export.&lt;/li&gt;
&lt;li&gt;  A constant &lt;code&gt;donut&lt;/code&gt; with a string value as a &lt;strong&gt;named&lt;/strong&gt; export.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;src/index.js&lt;/code&gt; is the file that interacts with the document.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  The &lt;strong&gt;default&lt;/strong&gt; export from &lt;code&gt;src/app/sayHello.js&lt;/code&gt; is  &lt;em&gt;imported&lt;/em&gt; to &lt;code&gt;src/index.js&lt;/code&gt; and is referred to as &lt;code&gt;Hello&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  Two variables are declared &amp;amp; defined, &lt;code&gt;name&lt;/code&gt; with a reference to a string value and &lt;code&gt;root&lt;/code&gt; referencing the &lt;code&gt;div&lt;/code&gt; HTMLElement w/ an ID of &lt;code&gt;'root'&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  The &lt;code&gt;Hello&lt;/code&gt; function (&lt;strong&gt;default&lt;/strong&gt; export from &lt;code&gt;src/app/sayHello.js&lt;/code&gt;) is called, and is provided
the previously declared &lt;code&gt;name&lt;/code&gt; variable.&lt;/li&gt;
&lt;li&gt;  The &lt;em&gt;text content&lt;/em&gt; of the &lt;code&gt;div&lt;/code&gt; HTMLElement referenced by &lt;code&gt;root&lt;/code&gt; is updated to &lt;code&gt;'Helllloooo ' + name +'!'&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 1
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Branch: Master&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;First, we'll need to install Webpack. If you're using the example code, run &lt;code&gt;npm install/yarn&lt;/code&gt; from your command line. If you're creating your own project to follow along with, run &lt;code&gt;npm install webpack -D/yarn add webpack -D&lt;/code&gt;. The &lt;code&gt;-D&lt;/code&gt; flag will save Webpack as a &lt;em&gt;developer dependency&lt;/em&gt; (a dependency we use when making our application, but not something that the core functionality of the application needs).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Sometimes I run Webpack from the command line. I have Webpack installed globally in order to do this. If you want this option as well, run &lt;code&gt;npm install --global webpack/yarn global add webpack&lt;/code&gt; from the command line and restart your terminal. To check if Webpack is installed correctly, run &lt;code&gt;webpack --version&lt;/code&gt; from the command line.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Once Webpack is installed, update the "scripts" section of the &lt;code&gt;package.json&lt;/code&gt; file:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts" {
    "build:" "webpack"
},
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We've added a script, &lt;code&gt;npm run build/yarn build&lt;/code&gt;, which can be called from the command line. This script will call on Webpack (which was installed as a &lt;em&gt;developer dependency&lt;/em&gt; via &lt;code&gt;npm install webpack -D/yarn add webpack -D&lt;/code&gt;). From the command line, run &lt;code&gt;npm run build/yarn build&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Error message!&lt;/strong&gt; Woo!&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;No configuration file found and no output filename configured via CLI option.
A configuration file could be named 'webpack.config.js' in the current directory.
Use --help to display the CLI options.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As far as error messages go, this one is pretty friendly. Webpack can be run in many ways, two of which are mentioned in this error message; the &lt;em&gt;command line interface&lt;/em&gt; (CLI) or a &lt;em&gt;configuration&lt;/em&gt; file. We'll be using a mixture of these two options by the end, but for now let's focus on the configuration file. The error message mentions that a configuration file could be named &lt;code&gt;webpack.config.js&lt;/code&gt;; you can name your configuration file whatever you want to. You can name it &lt;code&gt;chicken.cat.js&lt;/code&gt;. As long as that file exports a valid configuration object, just point Webpack in the right direction by using the &lt;code&gt;--config&lt;/code&gt; flag. Example (from command line or as package.json script): &lt;code&gt;webpack --config chicken.cat.js&lt;/code&gt;. If, however, you name your file &lt;code&gt;webpack.config.js&lt;/code&gt;, Webpack will find it without the need for the &lt;code&gt;--config&lt;/code&gt; flag. With great power comes great responsibility, etc.&lt;/p&gt;

&lt;p&gt;We know that Webpack failed because we didn't configure it properly, so let's create a configuration file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Branch: init&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There's a new file in this branch named &lt;code&gt;webpack.config.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./src/index.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./build/bundle.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;extensions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;...wat&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Yeah, me too. Let's break this down! First, let's rewrite this without the arrow function and so the &lt;code&gt;output&lt;/code&gt; and &lt;code&gt;resolve&lt;/code&gt; objects are split into multiple lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./src/index.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./build/bundle.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;extensions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Currently we're not doing anything with this 'env' argument, but we might use it later. Exporting a function is an option, but at the end of the day all Webpack cares about is getting a JavaScript object with the key/value pairs that Webpack knows. In which case this example could be further simplified to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Oh hey look! Somewhere in that mess was a good ol' JavaScript object. The kind &lt;/span&gt;
&lt;span class="c1"&gt;// you can 'sit down and have a beer with'.&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./src/index.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./build/bundle.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;extensions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This object has 3 keys: entry, output, and resolve. &lt;strong&gt;Entry&lt;/strong&gt; defines the entry point of our application; in our case, it's the &lt;code&gt;index.js&lt;/code&gt; file. This is the file that first interacts with the HTML document and kicks off any communication between the other JS files in the application. &lt;strong&gt;Output&lt;/strong&gt; is an object which contains options for configuring how the application's files should be bundled and outputted. In our case, we want our application to be bundled into a single file, &lt;code&gt;bundle.js&lt;/code&gt;, which should be placed inside a folder named &lt;code&gt;build/&lt;/code&gt;. &lt;strong&gt;Resolve&lt;/strong&gt; is an object with an array &lt;code&gt;extensions&lt;/code&gt; that has a single value, '.js'. This tells Webpack that if it comes across any &lt;code&gt;import&lt;/code&gt; statements that don't specify the extension of the file that the &lt;code&gt;import&lt;/code&gt; statement is targeting, assume that it's a &lt;code&gt;.js&lt;/code&gt; file. For example, if Webpack sees this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Hello&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./app/sayHello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Given the configuration provided, it would know to treat this as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Hello&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./app/sayHello.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To recap: The file &lt;code&gt;webpack.config.js&lt;/code&gt; exports a &lt;em&gt;function which returns an object&lt;/em&gt; (that's what the whole &lt;code&gt;module.exports = env =&amp;gt; ({ /*...Webpack config here...*/ })&lt;/code&gt; thing is). The object that is returned consists of key/value pairs which is used to configure Webpack so that it can parse through our application and create a bundle. Currently, we're providing Webpack with the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Where our application starts (entry)&lt;/li&gt;
&lt;li&gt;Where we want our bundle to go and how we want it to look (output.filename)&lt;/li&gt;
&lt;li&gt;How Webpack should treat imports that don't specify file extension (resolve.extensions)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, if we call &lt;code&gt;npm run build/yarn build&lt;/code&gt; from the command line, Webpack should be able to do it's thing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm run build
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; example@1.0.0 build /Projects/dev_to/webpack_configs/example
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; webpack

Hash: fa50a3f0718429500fd8
Version: webpack 2.5.1
Time: 80ms
            Asset     Size  Chunks             Chunk Names
./build/bundle.js  3.78 kB       0  &lt;span class="o"&gt;[&lt;/span&gt;emitted]  main
   &lt;span class="o"&gt;[&lt;/span&gt;0] ./src/app/sayHello.js 286 bytes &lt;span class="o"&gt;{&lt;/span&gt;0&lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;built]
   &lt;span class="o"&gt;[&lt;/span&gt;1] ./src/index.js 426 bytes &lt;span class="o"&gt;{&lt;/span&gt;0&lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;built]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There should now be a new folder &lt;code&gt;build/&lt;/code&gt; with a file &lt;code&gt;bundle.js&lt;/code&gt;. According to the output from calling &lt;code&gt;npm run build&lt;/code&gt;, this file consists of &lt;code&gt;./src/app/sayHello.js&lt;/code&gt; and &lt;code&gt;./src/index.js&lt;/code&gt;. If we look at this file and look at lines 73-90 we see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="cm"&gt;/* harmony default export */&lt;/span&gt; &lt;span class="nx"&gt;__webpack_exports__&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Hello &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;donut&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I WANT YOUR DONUTS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="cm"&gt;/* unused harmony export donut */&lt;/span&gt;


&lt;span class="cm"&gt;/**
 * Same code, ES5(-ish) style:
 * 
 * var donut = 'I WANT YOUR DONUTS';
 * 
 * module.exports = function(name) {
 *    return alert('Hello ' + name);
 * };
 * exports.donut = donut;
 * 
 */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's &lt;code&gt;./src/app/sayHello.js&lt;/code&gt;, and would you look at that, Webpack knew that even though &lt;code&gt;const donut&lt;/code&gt; was &lt;em&gt;exported&lt;/em&gt; from the file, it wasn't used anywhere in our application, so Webpack marked it with &lt;code&gt;/* unused harmony export donut */&lt;/code&gt;. Neat! It did some (read: a lot) of other stuff too, like changing the &lt;code&gt;export&lt;/code&gt; syntax into...something else entirely. &lt;code&gt;./src/index.js&lt;/code&gt; can be seen in lines 97-111. This time, anywhere that a piece of code from &lt;code&gt;./src/app/sayHello.js&lt;/code&gt; is used, it's been swapped out for something else.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;defineProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__webpack_exports__&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;__esModule&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="cm"&gt;/* harmony import */&lt;/span&gt; &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;__WEBPACK_IMPORTED_MODULE_0__app_sayHello__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;__webpack_require__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Import whatever the default export is from /app/sayHello&lt;/span&gt;
&lt;span class="c1"&gt;// and refer to it in this file as 'Hello'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Nitish&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Reference to the &amp;lt;div id="root"&amp;gt; element in&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Call the function that was imported from /app/sayHello, passing in&lt;/span&gt;
&lt;span class="c1"&gt;// `const name` that was created on line 5.&lt;/span&gt;
&lt;span class="nx"&gt;__webpack_require__&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;i&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__WEBPACK_IMPORTED_MODULE_0__app_sayHello__&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="cm"&gt;/* default */&lt;/span&gt;&lt;span class="p"&gt;])(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`Helllloooo &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;!`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Going over everything that is happening in the bundle is best saved for another post; the intention of looking at this file to prove that, yes, Webpack did indeed go through our code and place it all into one file.&lt;/p&gt;

&lt;p&gt;If we remember, the &lt;code&gt;index.html&lt;/code&gt; document had a &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag which referenced this bundled JS file. Open &lt;code&gt;index.html&lt;/code&gt; in your browser to be greeted by an alert and a sentence inside a div! Congratulations, you've used Webpack to create a bundle!&lt;/p&gt;

&lt;p&gt;EDIT: &lt;a href="https://dev.to/nitishdayal/stages-of-learning-webpack-pt-3---sourcemaps-loaders--plugins"&gt;Part 3 is finally up!&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webpack</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Stages of Learning Webpack</title>
      <dc:creator>Nitish Dayal</dc:creator>
      <pubDate>Mon, 15 May 2017 22:26:29 +0000</pubDate>
      <link>https://dev.to/nitishdayal/stages-of-learning-webpack</link>
      <guid>https://dev.to/nitishdayal/stages-of-learning-webpack</guid>
      <description>&lt;p&gt;&lt;em&gt;DISCLAIMER&lt;/em&gt;: This post doesn't provide any valuable information. It's mostly just for fun, and to share the struggles and 'Aha!' moments that some of us might have mutually experienced.&lt;/p&gt;




&lt;p&gt;Purpose of this post:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Webpack is worth learning. It is &lt;strong&gt;so much more&lt;/strong&gt; than a module bundler. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A few months back, I wrote a post on here about my first experience with configuring TypeScript + React and Webpack. That configuration was, apparently, terrible. So terrible that I decided to delete that post because I was giving out a lot of misinformation (also I looked really stupid ðŸ¤·ðŸ¾”â™‚ï¸). I've learned a bit more about Webpack since then and would like to take another crack at that post. And, preferably, do it right. But first, I wanted to share a summary of my Webpack learning experience (because light humor and humility are good things).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;strong&gt;Stages of Learning Webpack&lt;/strong&gt; &lt;em&gt;(from Jan-April)&lt;/em&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;I write (copy/paste) my first config. I have no idea what the hell I'm doing, but according to the Twitter HypeTrainâ„¢, I &lt;strong&gt;need&lt;/strong&gt; Webpack. I run Webpack and end up with a 2MB bundle for a 'Hello World', which is now broken with error messages I'm positive are written in some alien language. Baffled, I start changing things, still no clue what the hell I'm doing. Just...panicked, trying to figure out why this thing that was supposed to make my app smaller just made it like 500x bigger. &lt;em&gt;How did I manage to break this so badly?&lt;/em&gt; I headdesk the night away.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Aha! I did a thing! My app is working and WAY smaller! 200kb?! &lt;strong&gt;Daaaaaaaaang boi!&lt;/strong&gt; I'm stoked! I still have no idea what the hell is going on, but I'm so excited I decide to make it into a &lt;a href="https://github.com/nitishdayal/react_from_scratch" rel="noopener noreferrer"&gt;starter/boilerplate&lt;/a&gt; and write a blog about it. It's up for two months. &lt;em&gt;For whatever reason, no one bothers to let me know...hey, you're doing it wrong and it should be &lt;strong&gt;WAY&lt;/strong&gt; smaller.&lt;/em&gt; I keep headdesking away.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fxf0apprk64sawysnyw94.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fxf0apprk64sawysnyw94.png" title="Screenshot of commit message from my first working Webpack config ðŸŽŠ" alt="alt text" width="800" height="341"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I now have a basic idea of what the hell I'm doing. Webpack is a thing. It takes an object with some key/value stuff. It uses the key/value stuff to go through my app and, based on what keys/values are provided, creates a bundled version of my app. It might be big; it might be small. The point is that it's bundled. Anything after that is my call. 'My call' has graduated from &lt;em&gt;randomly changing things and hoping for the best&lt;/em&gt; to &lt;em&gt;docs &amp;gt; find the thing &amp;gt; install the thing, if necessary &amp;gt; use the thing&lt;/em&gt;. Apparently this object can actually be a function that &lt;em&gt;returns&lt;/em&gt; an object? Whatever. Embarrassed that I ever wrote/published that original article, I find it and delete it &lt;strong&gt;immediately&lt;/strong&gt;. I want a redo, and I want to do it right. I headdesk on.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Webpack docs and I are tight. I know where to go to find what I need, but I've been breaking/remaking these configs for so many months, at this point the docs are a fallback. Webpack is, officially, the homie. I can probably set up a dev environment with separate webpack configs for dev/prod/staging in a short period of time. I have opinions on what loaders and plugins to use when/why. I've had conversations about separate vs. single webpack config files; conversations which generally ended with either party giving the ol' eye-roll and 'agree-to-disagree' spiel. &lt;em&gt;Opinions, right?&lt;/em&gt; Am I a pro? By no means. Do I have a general understanding of the tool, the problems it attempts to solve, the benefits I can potentially gain from it, and why it is that I apparently &lt;strong&gt;needed&lt;/strong&gt; this thing? Absolutely.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I'll have another post tomorrow which details:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;   What is Webpack? Do I &lt;em&gt;really&lt;/em&gt; need it? (spoiler: probably not, but you might benefit from it)&lt;/li&gt;
&lt;li&gt;   The changes I've made to the &lt;a href="https://github.com/nitishdayal/react_from_scratch" rel="noopener noreferrer"&gt;boilerplate&lt;/a&gt; since the last post, and why&lt;/li&gt;
&lt;li&gt;   Recommendations &amp;amp; tips for navigating the documentation&lt;/li&gt;
&lt;li&gt;   Templates for a few of the more typical front-end development setups I've come across&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you see opportunities for improvements in the boilerplate configuration, please contact me/submit a PR. Thanks for reading! âœŒðŸ¾&lt;/p&gt;

&lt;p&gt;EDIT: &lt;a href="https://dev.to/nitishdayal/stages-of-learning-webpack-pt-2---the-config"&gt;Part 2&lt;/a&gt; is up!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webpack</category>
    </item>
    <item>
      <title>Nitish Dayal</title>
      <dc:creator>Nitish Dayal</dc:creator>
      <pubDate>Tue, 25 Apr 2017 10:58:14 +0000</pubDate>
      <link>https://dev.to/nitishdayal/nitish-dayal</link>
      <guid>https://dev.to/nitishdayal/nitish-dayal</guid>
      <description>&lt;p&gt;Tunes and tech. I'm...very boring.&lt;/p&gt;

&lt;p&gt;Twitter: &lt;a href="https://twitter.com/nitish_dayal" rel="noopener noreferrer"&gt;@nitish_dayal&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Employment Status: Taken â¤ï¸&lt;/p&gt;

&lt;p&gt;Programming Languages I'm familiar with: JavaScript(ES5 and on, TypeScript, Flow), Swift (3), Python(2.7,3)&lt;/p&gt;

&lt;p&gt;Studying: Functional programming, design patterns, type systems.&lt;/p&gt;

&lt;p&gt;Work with me on something! &lt;a href="////github.com/nitishdayal"&gt;Github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>introduction</category>
    </item>
  </channel>
</rss>
