<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Garima Bhatia on Medium]]></title>
        <description><![CDATA[Stories by Garima Bhatia on Medium]]></description>
        <link>https://medium.com/@garimabhatia806?source=rss-b2462de8da3e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*GdI-3F-6ll-c68Si.</url>
            <title>Stories by Garima Bhatia on Medium</title>
            <link>https://medium.com/@garimabhatia806?source=rss-b2462de8da3e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 16:33:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@garimabhatia806/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Comparing bundlers: Webpack, Rollup & Parcel]]></title>
            <link>https://medium.com/js-imaginea/comparing-bundlers-webpack-rollup-parcel-f8f5dc609cfd?source=rss-b2462de8da3e------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8f5dc609cfd</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[parcel-js]]></category>
            <category><![CDATA[rollup]]></category>
            <dc:creator><![CDATA[Garima Bhatia]]></dc:creator>
            <pubDate>Tue, 12 Jun 2018 05:11:30 GMT</pubDate>
            <atom:updated>2019-04-22T06:30:16.291Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*IBDTM5koR2Qrn7iOJOE3pg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z-sMguwfEhrYf8_Ixr_drQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*hHkTMpC5JtJzTEwL8P6kng.png" /></figure><blockquote><strong>Module Bundling In Javascript:</strong></blockquote><p>Module Bundling, on a high level, is a process of integrating together a group of modules in a single file so that multiple modules can be sent to the browser in a single bundle.</p><p>When we write our code in a modular pattern:</p><ul><li>We keep our javascript in separate files and folders based on functionality.</li><li>Add the script tag for each file that we are using in correct order of dependency.</li></ul><p>For each script tag , browser will send the request to the server which will have bad effect on the performance of our application. In order to overcome this we usually create a single bundled file which will integrate all the other files and that bundled file is sent to browser.</p><p>Module bundling can also include a minification step i.e. all the unnecessary characters like space, comma, comments etc. are removed from the file and its minified version is created and whenever a request comes from the browser that minified version is sent back. Less data means less browser processing time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*cwioCVGubOXJ9F1KQW8Slg.png" /><figcaption>normal script</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*0wKTt2TqHvBj2f63EgMRUw.png" /><figcaption>minified script</figcaption></figure><p>Apart from creating a bundle and minifying the code, a module bundler also provides features for good developer experience such as hot reloading, code splitting etc.</p><p>There are a lot of module bundlers in market today like webpack, browserify, rollup, parcel etc. Here we will be focusing on comparision between webpack, rollup and parcel.</p><blockquote><strong>Webpack vs Rollup vs Parcel :</strong></blockquote><p>All these bundlers came up with a different approach of solving a problem which existing tools couldn’t solve.</p><p>Webpack was designed to solve the problems of asset management (i.e. it can include any type of file, even non-javascript files) and code splitting. It’s very flexible and has a huge amount of plugins for every use-case you could imagine.</p><p>Rollup, on the other hand, came up with the idea of using a standardised format (i.e. ES2015 module format) to write your code and tries to get really small builds with the help of dead code elimination.</p><p>Parcel tries to give you “blazing fast” bundling as it uses multiple worker processes to ensure that the compilation process is executed in parallel on multiple cores without the need of any configuration.</p><p>I will be doing further comparisions between these three on the following points:</p><h4><strong>1. Configuration:</strong></h4><p>Webpack and rollup both require a config file for applications. The config file contains the options related to entry, output, plugin, transformations etc. There is a slight difference between rollup and webpack config file.</p><ul><li>Rollup has node polyfills for import/export, whereas webpack doesn’t.</li><li>Rollup has support for relative paths, whereas webpack does not, so we either use path.resolve or path.join.</li></ul><p>Parcel, on the other hand doesn’t require any config file to be specified. It will do everything out of the box.</p><h4>2.<strong> Entry points:</strong></h4><p>Webpack supports only javascript file as entry point in config file. In order to support other formats such as html we need to add third party plugins.</p><p>Rollup can take an html file as entry point but in order to make that happen we need to install a plugin (eg. rollup-plugin-html-entry).</p><p>Parcel can take <em>index.html</em> file as entry file and it figures out which javascript bundles to create and download by looking at the script tag in the index.html file.</p><h4>3. <strong>Transformations:</strong></h4><p>Module bundlers require javascript files to create a bundle. They cannot process any other format directly. So, in order to process files other than javascript , we need to first convert that format into javascript then we will pass it to the bundler. This process of conversion is called transformation.</p><p>Webpack uses loaders of different formats for transformation. eg: style-loader, css-loader for css files. We need to configure the file type and corresponding loader to be used in it’s config file.</p><p>Rollup uses plugins for transformation. We need to specify the plugin in the rollup config file.</p><p>Parcel supports various transformations like css, scss , images etc without config file. Parcel automatically runs these transforms when it finds a configuration file (e.g. .babelrc, .postcssrc) in a module.</p><h4>4. Tree Shaking:</h4><p>Tree shaking, in javascript context, refers to dead code elimination.</p><p>In order to implement tree shaking in webpack we need to:</p><ul><li>Use ES2015 module syntax (i.e. import and export).</li><li>Add a “sideEffects” entry to your project’s package.json file.</li><li>Include a minifier that supports dead code removal (e.g. the UglifyJSPlugin).</li></ul><p>Rollup statically analyzes the code you are importing, and will exclude anything that isn’t actually used. This allows you to build on top of existing tools and modules without adding extra dependencies or bloating the size of your project.</p><p>Parcel doesn’t support tree shaking yet.</p><h4>5. Dev Server :</h4><p>A development server is a type of server that is designed to facilitate the development and testing of programs, websites, software or applications for software programmers. It provides a run-time environment, as well as all hardware/software utilities that are essential to program debugging and development.</p><p>Webpack provides a plugin called webpack-dev-server which provides a simple development server with live reload functionality. We need to add this plugin in our project and add some configuration specifying the file to serve when we run this and a script to run webpack-dev-server in package.json.</p><p>To implement development server in rollup, we need to install rollup-plugin-serve which will just rebuild the script whenever we make any changes but in order to provide live reload functionality we need to install another plugin rollup-plugin-livereload. Both the plugins need to be configured.</p><p>Parcel has a development server built in, which will automatically rebuild your app as you change files.</p><h4>6. Hot Module Replacement :</h4><p>Hot Module Replacement (HMR) exchanges, adds, or removes modules while an application is running, without a full reload. This can significantly speed up development.</p><p>Hot Module Replacement is one of the most useful features offered by webpack. It allows all kinds of modules to be updated at runtime without the need for a full refresh. webpack-dev-server supports a hotmode in which it tries to update with HMR before trying to reload the whole page.</p><p>Rollup doesn’t do hot module replacement (HMR).</p><p>Parcel has built-in support for hot module replacement.</p><h4>7. <strong>Code Splitting :</strong></h4><p>Loading application code can take a long time, especially on mobile. Code-splitting breaks your app into smaller chunks, so that the user only has to load enough JavaScript to get started, and the application can quietly fetch the rest whenever it becomes relevant.</p><p>Code Splitting is the most compelling feature of webpack. There are three general approaches to code splitting available in webpack:</p><ul><li>Entry Points: Manually split code using <a href="https://webpack.js.org/configuration/entry-context">entry</a> configuration.</li><li>Prevent Duplication: Use the <a href="https://webpack.js.org/plugins/commons-chunk-plugin">CommonsChunkPlugin</a> to dedupe and split chunks.</li><li>Dynamic Imports: Split code via inline function calls within modules.</li></ul><p>Rollup has recently added experimental code splitting feature. Split chunks created by rollup are <em>themselves</em> just standard ES modules that use the browser’s built-in module loader without any additional overhead. We need to set experimentalCodeSplitting and experimentalDynamicImport flags to true in the config file.</p><p>Parcel supports zero configuration code splitting. Here code splitting is controlled by use of the dynamic import() function <a href="https://github.com/tc39/proposal-dynamic-import">syntax proposal</a>, which works like the normal import statement or require function, but returns a Promise. This means that the module is loaded asynchronously.</p><p>To demonstrate this, I have created a small project using each of the above bundlers. I have added the basic configuration in the project.</p><blockquote>Rollup-config:</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d68bc05304099bdff23f9ff60804d86/href">https://medium.com/media/5d68bc05304099bdff23f9ff60804d86/href</a></iframe><blockquote>webpack-config:</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b86c8bc77cc702ba4b870e976e2b7fd/href">https://medium.com/media/8b86c8bc77cc702ba4b870e976e2b7fd/href</a></iframe><blockquote><strong>Build</strong> <strong>Results:</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*cZwg_uId_cAl7KUKq1hvhg.png" /><figcaption>webpack build took 4.13 seconds time.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*vjgVu5x-jptGge_lgfLvZw.png" /><figcaption>Rollup took 3.3seconds time.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*CKVPCjtUPxiiY0LBeiVwqg.png" /><figcaption>parcel took 8.86 seconds time.</figcaption></figure><p>Below are the github links.</p><blockquote>Links:</blockquote><p><a href="https://github.com/garima33/webpack-react-boiler-plate/">webpack-react-boiler-plate</a></p><p><a href="https://github.com/garima33/react-rollup-boiler-plate">rollup-react-boiler-plate</a></p><p><a href="https://github.com/garima33/parcel-react-boiler-plate">parcel-react-boiler-plate</a></p><p>Originally posted at <a href="https://blog.imaginea.com/comparing-javascript-module-bundlers-webpack-rollup-or-parcel/">blog.imaginea.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8f5dc609cfd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/js-imaginea/comparing-bundlers-webpack-rollup-parcel-f8f5dc609cfd">Comparing bundlers: Webpack, Rollup &amp; Parcel</a> was originally published in <a href="https://medium.com/js-imaginea">js@imaginea</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A small peak in the world of emotion-js]]></title>
            <link>https://medium.com/js-imaginea/a-small-peak-in-the-world-of-emotion-js-ac2df2e9b3db?source=rss-b2462de8da3e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac2df2e9b3db</guid>
            <category><![CDATA[javascript-library]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Garima Bhatia]]></dc:creator>
            <pubDate>Tue, 03 Apr 2018 06:25:42 GMT</pubDate>
            <atom:updated>2018-09-04T13:18:38.680Z</atom:updated>
            <content:encoded><![CDATA[<p>when CSS1 was released, the intent of the specification was to separate the presentation of a document from the document content.The web was not mainstream then and content was still largely document based. Stylesheets were small those days and the overhead of maintainence was less as compared to the benefits that we got from decoupling the content and the presentation.</p><p>In the modern web, we rarely think of content in the context of a document. The modern web is dominated by highly dynamic web applications with graphically intensive stylings. Today’s production stylesheets can easily reach into the thousands of lines of code with several hundred selectors.</p><p>Below are some of the problems that we face with regular css while scaling our application.</p><p><strong>1. Global Namespace </strong>: CSS is global, and every rule you write has the potential to affect entirely unrelated parts of the site.</p><p><strong>2. Naming Collisions : </strong>With a team of developers working on same project chances of naming collisions increases which can have side effects on the overall application.</p><p><strong>3. Dead Code Elimination : </strong>Your class names and styles (i.e. .css files) are separately located to what is being styled, typically JSX with className or in non-React projects, as separate HTML files. Additionally, as previously mentioned, as CSS is global by default, your styles could be styling unrelated functionality in your application. Jointly, these two concerns make it incredibly difficult to re-factor unused CSS.</p><p><strong>4. Sharing Constants: </strong>Sharing constants between css and Js is not ideal but there are unfortunately many real world use cases where you need to do it. We have been using comments to solve this issue.</p><p>There is a very good <a href="https://speakerdeck.com/vjeux/react-css-in-js">presentation</a> made my Christopher Chedeau in which he has discussed the problems arising with regular css and the concept of CSS in JS.</p><blockquote><strong><em>Css in Js</em></strong></blockquote><p>Css in Js is a more powerful abstraction over CSS. It uses the JavaScript as a language to describe styles in a declarative and maintainable way. It is a <a href="http://cssinjs.org/performance">high performance</a> JS to CSS compiler which works at runtime and server-side.</p><p>There are so many css-in-js libraries available today. But we are going to discuss about Emotion.</p><blockquote><strong>Emotion-js</strong></blockquote><p>Emotion is a performant and flexible CSS-in-JS library. It’s inspired by many other CSS-in-JS libraries like <a href="https://github.com/threepointone/glam/tree/e9bca3950f12503246ed7fccad5cf13e5e9c86e3">glam</a>, <a href="https://github.com/threepointone/glamor">glamor</a>, <a href="https://www.styled-components.com/">styled-components</a> and <a href="https://glamorous.rocks/">glamorous</a>. It allows you to style applications quickly with string styles or object styles. It has predictable composition to avoid specificity issues with CSS.</p><blockquote><strong>Css</strong></blockquote><p>The primary way to style things in emotion is with css, it accepts styles as a template literal, object, or array of objects and returns a class name.</p><pre>import { css } from &#39;emotion&#39;</pre><pre>return(&lt;div<br>  className={css`<br>   color: hotpink;<br>  `}<br> &gt;)</pre><blockquote><strong>Styled Components</strong></blockquote><p>Styled is a thin wrapper around css. It is used to create react components that have styles attached to them. Styled components also accepts props which can be used to customize the styles.</p><pre>import styled from &#39;react-emotion&#39;</pre><pre>const Button = styled(&#39;button&#39;)`<br> color: turquoise;<br>`</pre><pre>render(&lt;Button&gt;This my button component.&lt;/Button&gt;)</pre><p>To demonstrate this I have created a small application which is displaying some user cards in a grid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V1R73lA18J9DEiRUfXcaXQ.jpeg" /></figure><p>My application basically consists two components one is the grid container containing all the cards and another is a single card in the grid. I am using styled components of react-emotion.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e1836d8de8293ce57f68ea0b723021a1/href">https://medium.com/media/e1836d8de8293ce57f68ea0b723021a1/href</a></iframe><p>Flex and DataWrapper are styled components that i will be using in my main container component. Flex can be used at multiple places wherever we want flex layout. Just like background color, we can customize other styles as well to increase the reusability.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d00a08b48a1d2388c74fe2f8518a61b7/href">https://medium.com/media/d00a08b48a1d2388c74fe2f8518a61b7/href</a></iframe><p>Below is my Card component.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9be3e98e6c684a57c9e1d6130b8f43d/href">https://medium.com/media/c9be3e98e6c684a57c9e1d6130b8f43d/href</a></iframe><blockquote><strong>Advantages:</strong></blockquote><ol><li>Problem of global namespace has been resolved as it generates unique hash based classname for each component while render.</li><li>We can create customized reusable components as we can pass customized styles as props to our styled components.</li><li>As the styles are tightly coupled with the components there won’t be any unwanted side effects on the DOM.</li><li>We can create customized semantic components and use the same over entire application maintaining the consistency.</li></ol><blockquote><strong>Links:</strong></blockquote><p>To see the whole code you can refer the following links:</p><ol><li><a href="https://github.com/garima33/grid-demo">grid-demo with regular css</a></li><li><a href="https://github.com/garima33/grid-emotion-demo">grid-demo with emotion</a></li></ol><p>Originally posted at <a href="https://blog.imaginea.com/a-small-peak-in-the-world-of-emotion-js/">blog.imaginea.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac2df2e9b3db" width="1" height="1" alt=""><hr><p><a href="https://medium.com/js-imaginea/a-small-peak-in-the-world-of-emotion-js-ac2df2e9b3db">A small peak in the world of emotion-js</a> was originally published in <a href="https://medium.com/js-imaginea">js@imaginea</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>