Webpack 2 The last bundler you would need in Vijay Dharap, Principal Architect, Infosys

Similar documents
Chapter 1 - Development Setup of Angular

55249: Developing with the SharePoint Framework Duration: 05 days

Full Stack boot camp

"Charting the Course... MOC A: Developing with the SharePoint Framework. Course Summary

LeanJS Documentation. Release Romain Dorgueil

Webpack. What is Webpack? APPENDIX A. n n n

MOdern Java(Script) Server Stack

Web Development for Dinosaurs An Introduction to Modern Web Development

This tutorial has been prepared for beginners to help them understand the basic functionalities of Gulp.

Cisco Spark Widgets Technical drill down

Introduction to Using NPM scripts as a Build Tool. 1. 1

ReactJS and Webpack for Rails

Vue.js Developer friendly, Fast and Versatile

Web Performance in

Tools. SWE 432, Fall Design and Implementation of Software for the Web

Comprehensive AngularJS Programming (5 Days)

Modern frontend workflows in Liferay Portal and Liferay DXP. Iván Zaera Avellon, Liferay Chema Balsas, Liferay Pier Paolo Ramon, SMC

Offline-first PWA con Firebase y Vue.js

Angular 2 Programming

Frontend UI Training. Whats App :

A JavaScript Framework for Presentations and Animations on Computer Science

React(.js) the Domino Way High-Performance Client for Domino. Knut Herrmann

RequireJS Javascript Modules for the Browser. By Ben Keith Quoin, Inc.

Evolution of the "Web

Getting Started with ReactJS

Welcome. Quick Introductions

Developing ASP.NET MVC Web Applications (486)

Lab 1 - Introduction to Angular

APACHE SLING & FRIENDS TECH MEETUP SEPTEMBER Integrating a Modern Frontend Setup with AEM Natalia Venditto, Netcentric

Index. Elad Elrom 2016 E. Elrom, Pro MEAN Stack Development, DOI /

Modern SharePoint and Office 365 Development

70-486: Developing ASP.NET MVC Web Applications

webpack bundle inner structure and optimization Alexey Ivanov, Evil Martians

Creative Techniques for Loading Web Pages Faster

PWA s are the future!

Arjen de Blok. Senior Technical Consultant bij ICT Groep ( sinds 1995 Programmeren sinds 1990 Technologiën. Links

welcome to BOILERCAMP HOW TO WEB DEV

Making Sling Grunt Or How to Integrate Modern Front-End Development with Sling. Philip Hornig (Publicis Pixelpark), Michael Sunaric (Netcentric)

WP1. Coordination, Management and Dissemination. Deliverable D1.1. Project Website

Stencil: The Time for Vanilla Web Components has Arrived

WebStorm, intelligent IDE for JavaScript development

CREATE SASSY WEB PARTS. Developer Guide to SASS usage in SPFx

WEBASSETS & DUKPY FREE YOURSELF FROM NODEJS. Alessandro amol

Node.js. Node.js Overview. CS144: Web Applications

Build Powerful FrontEnd Workflows with PostCSS. Guide to writing/generating cutting edge CSS

FRONT END WEB. {< Course Details >}

How to use jquery file. How to use jquery file.zip

Drupal Frontend Performance & Scalability

Your essential APEX companion. Marko apexbyg.blogspot.com

Indium Documentation. Release Nicolas Petton

An Automatic Internationalization and Localization Mechanism for Web Applications

Lab 6: Testing. Software Studio DataLab, CS, NTHU

Advance Mobile& Web Application development using Angular and Native Script

django-baton Documentation

P a g e 1. Danish Technological Institute. Scripting and Web Languages Online Course k Scripting and Web Languages

The Why And How of Front-End Architecture. Feel the rhythm, feel the rhyme, get on up, it s front-end time

THE UPGRADE AND DESIGN OF REMOTE MONITOR AND CONTROL FOR CLIMATE CHAMBER

Introduction to the SharePoint Framework Bob German Principal Architect - BlueMetal. An Insight company

pyramid_assetmutator Documentation

Ionic CLI is the default and easiest way to work with ionic projects. In this tutorial we will learn the ins and outs of Ionic CLI.

PROCE55 Mobile: Web API App. Web API.

Guides SDL Server Documentation Document current as of 04/06/ :35 PM.

Overview of BC Learning Network SMS2 Introduction

Catbook Workshop: Intro to NodeJS. Monde Duinkharjav

Learn Gulp. Jonathan Birkholz. This book is for sale at This version was published on

JavaScript and MVC Frameworks FRONT-END ENGINEERING

Introduction to Sencha Ext JS

A Motivating Example: Building a Static Website

JavaScript on the Command Line & PRATIK PATEL CTO TripLingo Labs

django-baton Documentation

Guides SDL Server Documentation Document current as of 05/24/ :13 PM.

Quick Desktop Application Development Using Electron

DrupalCon Barcelona Preston So September 22, 2015

Brunch Documentation. Release Brunch team

Getting started with Tabris.js Tutorial Ebook

30 th September 2017 Milan

Software Architecture Documentation for the JRC MYGEOSS app for Invasive Species project

JavaScript & Security get married. Yan Zhu NCC Group SF Open Forum 9/17/15

Introduction and first application. Luigi De Russis. Rails 101

Web UI. Survey of Front End Technologies. Web Challenges and Constraints. Desktop and mobile devices. Highly variable runtime environment

Salvatore Rinzivillo VISUAL ANALYTICS

How to get a perfect 100 in Google PageSpeed Insights

INTRODUCTION TO IONIC 2

Speed Optimization PRO

KonaKart Shopping Widgets. 3rd January DS Data Systems (UK) Ltd., 9 Little Meadow Loughton, Milton Keynes Bucks MK5 8EH UK

Mobile LREC. Dimension: Mobile: 640 (W) x 500 (H) pixels (for News app now, available on mytv SUPER app since Jan 2018)

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML

EPUB in the Browser. Ben Walters Principle Software Engineering Lead at Microsoft

Presented by. Dheepa Iyer Managing Consultant. Commissioned for. Reston SharePoint User Group. SharePoint Framework. May 2017

React & Redux in Hulu. (Morgan Cheng)

Introduction to TypeScript

HPE Software, Cloud and Automation

High Performance Single Page Application with Vue.js

Quick.JS Documentation

Front-End UI: Bootstrap

Creative Weight Best Practices

Brief Intro to Firebug Sukwon Oh CSC309, Summer 2015

PHP WITH ANGULAR CURRICULUM. What you will Be Able to Achieve During This Course

Building Mobile Apps with the ArcGIS API for JavaScript. Andy Gup, Lloyd Heberlie, Thomas Other

Advanced React JS + Redux Development

Transcription:

Webpack 2 The last bundler you would need in 2017 Vijay Dharap, Principal Architect, Infosys

Speaker Bio 14+ Years of experience Principal Architect in Infosys Passionate about delightful UX Open Source Evangelist and contributor Organizer for Yearly Tech Conferences within Infosys 2

Before we begin Let me know you guys a little Have you have used webpack before? Are you a web developer? Used anything like webpack? Grunt? Gulp? Have you worked with npm ecosystem?

WORLD WITHOUT WEBPACK

Step-00 AS-IS no webpack scenario npm install npm run server Access http://localhost:3000/step-00 in chrome. Observe loading in chrome devtools network tab

LETS INTRODUCE WEBPACK TO THE MIX

At its core, Webpack is a Loader Loads Javascript AND Non-Javascript files for processing. Post processing, it may add it into bundles. Bundler Bundles javascript assets into one or more bundles Set of Plugins add additional functionality to core webpack functionality

// App.js // webpack.config.js {... outputpath:./dist, } entry: app.js Application modules App.css App.js A.Component.ts Brand.png node_modules Normalize.css Module2.js Db.json webpack Parser (acorn) Compiler (bundler) Loader(s) Plugins File Emitter import * as _ from 'lodash'; import './module2.js'; import './app.css'; import db from './db.json'; import * as $ from 'jquery'; import { CompA } from './A.Component.ts'; ======================== /* app.css */ @import '~normalize.css';.brand { background-image: 'brand.png'; } jquery lodash dist bundle.e266902 342def232ba33. js brand.eda23 2388701db. png

Step-01 Let redo Step-00 example with webpack To run Step-01 npm run server npm run s1 Access http://localhost:3000/step-01 in chrome.

Data Transferred (kb) Request count # Time Taken (seconds) Effect of webpack Normal No bundling, no minification (Step-00) 3G Throttled 250 200 Webpacked 150 DEV (Step-02) 3G Throttle 100 50 Effect of webpack on build size Webpacked Production (Step-02) 3G Throttle 0 Step-00 Step-02 - DEV Step-02 - PROD Data Transferred 66.4 10.4 6.7 Request Count 203 2 2 Time taken 4.11 0.563 0.537 Data Transferred Request Count Time taken 4.5 4 3.5 3 2.5 2 1.5 1 0.5 0

What did we attain? Automatic JS Graph Parsing Huge improvement in Time to Interactive Webpack OOTB Minification HTTP Request Reduction

LET S LOAD IT UP!

Step-02 Load it up! Popular loaders Typical File name patterns Loader Name Bundles OR copies? *.js(x) babel-loader Bundles *.css Style-loader Css-loader Bundles *.scss Sass-loader Bundles *.html Html-loader Bundles Fonts (*.ttf, *.woff(2), *.eot) url-loader File-loader Copies *.json Json-loader Bundles *.ts To run Step-02 Typescript-loader Bundles npm run server npm run s2 Access http://localhost:3000/step-02 in chrome. Images( *jpg, *.png, *.gif) File-loader Copies

What did we attain? Automatic parsing of modules from node_modules directory via ~ shortcut. Tree-shaking (-p only) Loaded, Bundled / Copied the modules and other assets into deployable directory

Step-03 Dev-Server A web server via express live-reloading via sockjs! Hello BrowserSync! To run Step-03 npm run s3 Access http://localhost:3000 in chrome.

Step-04 - Customize to your satisfaction! Popular plugins Name DefinePlugin ProvidePlugin HtmlWebpackPlugin UglifyjsPlugin DLLBundlesPlugin + AddAssetsHTMLPlugin Description Defines ENV variables. Useful for environment specific variations. Provides for certain symbols so you do not have to declare them. Creates index.html with script bundle names added into it. UglifyJS integration automatically added for PRODUCTION Without DLL build time = 9.675 s With DLL build time = 6.967 s To run Step-04 npm run Internally s4 uses core webpack plugins (DllPlugin and Access DLLReferencePlugin) http://localhost:3000 in chrome. npm run s4:prod

Step-05 Code Splitting and Chunking Split the JS Chunks Different ways to split JS chunks Add multiple entries useful to logically split vendors modules. Why we should split vendors out? App Logical deployments will not invalidate the caches. Dynamic imports e.g. lazy loading Split out the CSS - ExtractTextWebpackPlugin To run Step-05 npm run server npm run s5 Access http://localhost:3000/step-05 in chrome.

What did we achieve? Lazy loading things which we do not need for homepage better TTI Splitting vendor improve on development turnaround time, Improve on cacheability in PROD environment Splitting CSS out of bundle Avoids FOUC using ExtractTextWebpack Plugin Automatic Cache Busting via hash in bundle name. SourceMaps

so.. We webpack because Versatile loading sytem Optimal size via Tree Shaking and minification Bundling and code splitting Cache busting Goodies like dev-sever, analyzer and awesome plugins

Credits Webpack.js.org Survivejs.com Repository https://github.com/dharapvj/learning-webpack2

Thank you

www.modsummit.com www.developersummit.com