SlideShare a Scribd company logo
1 of 33
Download to read offline
Webpack: from 0 to 2(.3.3)
Milano_JS
04.04.2017
Alessandro Bellini
frontend developer @ Spryker
- web: ilmente.com
- github: github.com/ilmente
- twitter: @ilmente
Agenda
- grunt, gulp and webpack
- webpack modules
- entry points
- loaders and plugins
- configuration - code overview
- code splitting - code overview
- tree shaking - code overview
in the beginning it was grunt
grunt
- focus on configurations
- built around a set of built-in commonly used tasks
- extension using plugins
- each plugin has its own custom configuration
- every task is an array of different plugin configurations, that
simply get executed one after another, in a strictly independent, and
sequential fashion
https://medium.com/@preslavrachev/gulp-vs-grunt-why-one-why-the-other-f5d3b398edc4
then came gulp
gulp
- focus on code
- micro-tasks connected to each other (agnostic about their nature)
- extension using plugins
- plugins use API to be programmed
- streams and pipelines
https://medium.com/@preslavrachev/gulp-vs-grunt-why-one-why-the-other-f5d3b398edc4
and now webpack
grunt
- focus on configurations
- built around a set of built-in commonly used tasks
- extension using plugins
- each plugin has its own custom configuration
- every task is an array of different plugin configurations, that
simply get executed one after another, in a strictly independent, and
sequential fashion
https://medium.com/@preslavrachev/gulp-vs-grunt-why-one-why-the-other-f5d3b398edc4
grunt webpack
- focus on configurations
- built around a set of built-in commonly used tasks
- extension using plugins
- each plugin has its own custom configuration
- every task is an array of different plugin configurations, that
simply get executed one after another, in a strictly independent, and
sequential fashion
close, but it’s not exactly like this...
grunt webpack
- focus on configurations
- built around a set of built-in commonly used tasks features
- extension using plugins and loaders
- each plugin/loader has its own custom configuration
- every task compile process (or step) is an array of different plugin
loaders (eventually configured/extend using plugins) configurations,
that simply get executed one after another, in a strictly
independent, and sequential fashion
- loaders can be chained together: this is helpful for applying
multiple transformations to a file in a pipeline
https://webpack.github.io/docs/loaders.html (webpack 1.x docs)
grunt - gulp - webpack
- grunt and gulp are task runners
- webpack is a module bundler
- gulp and webpack are not necessary enemies
You can use webpack with grunt/gulp:
- https://webpack.js.org/guides/task-test-runner/
(almost useless page)
- http://webpack.github.io/docs/usage-with-grunt.html
- http://webpack.github.io/docs/usage-with-gulp.html
webpack modules
not just modules
modules
- discrete chunk of functionality a program is broken into
- abstraction
- single responsability
- reusability
- better debugging and testing
webpack modules
- a dependency expressed by:
- import (es2015)
- require() (CommonJS)
- define() and require() (AMD)
- @import (css/sass/less)
- url() (stylesheet)
- <img src=””> (html)
(!) Please refer to https://webpack.js.org/concepts: it’s well done and explained
entry points
the root of the tree
- root of the tree
loaders and plugins
is this a kind of magic?
loaders
- functions
- transform the source code of a module
- synchronous or asynchronous
- can be configured with options
- can be chained
- can emit additional arbitrary files
https://webpack.js.org/concepts/loaders
plugins
- webpack backbone
- “anything else that a loader cannot do” (cit.)
- it’s wizardry
- can you do everything?
- may I have a coffee?
- hooks into the whole webpack build system
- allow you to access, change, extend any phase of the build process,
from resolving a module to bundling the output
https://webpack.github.io/docs/plugins.html
in a nutshell
- if you want to tell webpack how to load that specific type of
resource: use loaders
- everything else: use plugins
in a nutshell
- if you want to tell webpack how to load that specific type of
resource: use loaders
- everything else: use plugins
- if you want to change how this module is resolved and compiled: use
plugins
a real configuration
let’s switch to the code
code splitting
introducing performance superheroes
code splitting
- it’s a features
- split your code into various bundles
- smaller bundle size
- resource load prioritization control
- on-demand loading
- may have significant performance impact
- on build/rebuild time
- on application/site load time
- you have the freedom to choose and implement your own strategy to
optimise the assets management
https://webpack.js.org/guides/code-splitting/
- root of the tree
code splitting superheroes
- css
- style-loader
- ExtractTextWebpackPlugin
- vendor
- CommonsChunkPlugin
- on-demand
- import()
- require.ensure()
https://webpack.js.org/guides/code-splitting/
tree shaking
bullshit, myth
or shut-up-and-take-my-money feature?
tree shaking
- positive selection of actual used code (live code)
- in opposition to dead code removal (UglifyJs plugin)
- introduced in bundlers world by github.com/rollup/rollup
Known limitations for webpack:
- static structure
- relies on es2015 module import/export
https://webpack.js.org/guides/tree-shaking
the code said…
- babel:
- use preset babel-preset-es2015 with { “modules”: false }
- use plugin babel-plugin-syntax-dynamic-import
- limited to es2015 source code
- unable to shake objects or inside statements
- capable of dropping functions, but not classes
- uglifyJS plugin needed
https://webpack.js.org
it’s my main source
thanks
yes, it’s finally over…

More Related Content

What's hot

Bundle your modules with Webpack
Bundle your modules with WebpackBundle your modules with Webpack
Bundle your modules with WebpackJake Peyser
 
Webpack Introduction
Webpack IntroductionWebpack Introduction
Webpack IntroductionAnjali Chawla
 
Packing it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to nowPacking it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to nowDerek Willian Stavis
 
Packing for the Web with Webpack
Packing for the Web with WebpackPacking for the Web with Webpack
Packing for the Web with WebpackThiago Temple
 
Production optimization with React and Webpack
Production optimization with React and WebpackProduction optimization with React and Webpack
Production optimization with React and Webpackk88hudson
 
Bower & Grunt - A practical workflow
Bower & Grunt - A practical workflowBower & Grunt - A practical workflow
Bower & Grunt - A practical workflowRiccardo Coppola
 
Once upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingOnce upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingAndrea Giannantonio
 
Webpack and Web Performance Optimization
Webpack and Web Performance OptimizationWebpack and Web Performance Optimization
Webpack and Web Performance OptimizationChen-Tien Tsai
 
Advanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsAdvanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsk88hudson
 
Andrew Mykhaliuk - Sorry, I need to make a build for frontend
Andrew Mykhaliuk - Sorry, I need to make a build for frontendAndrew Mykhaliuk - Sorry, I need to make a build for frontend
Andrew Mykhaliuk - Sorry, I need to make a build for frontendOdessaJS Conf
 
Bundling your front-end with Webpack
Bundling your front-end with WebpackBundling your front-end with Webpack
Bundling your front-end with WebpackDanillo Corvalan
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationDavid Amend
 
Introduction to Express and Grunt
Introduction to Express and GruntIntroduction to Express and Grunt
Introduction to Express and GruntPeter deHaan
 
#2 Hanoi Magento Meetup - Part 2: Knockout JS
#2 Hanoi Magento Meetup - Part 2: Knockout JS#2 Hanoi Magento Meetup - Part 2: Knockout JS
#2 Hanoi Magento Meetup - Part 2: Knockout JSHanoi MagentoMeetup
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIWordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIBrian Hogg
 
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpOptimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpMatthew Davis
 

What's hot (20)

Webpack
WebpackWebpack
Webpack
 
Bundle your modules with Webpack
Bundle your modules with WebpackBundle your modules with Webpack
Bundle your modules with Webpack
 
Webpack Introduction
Webpack IntroductionWebpack Introduction
Webpack Introduction
 
Packing it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to nowPacking it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to now
 
Packing for the Web with Webpack
Packing for the Web with WebpackPacking for the Web with Webpack
Packing for the Web with Webpack
 
Webpack
WebpackWebpack
Webpack
 
Production optimization with React and Webpack
Production optimization with React and WebpackProduction optimization with React and Webpack
Production optimization with React and Webpack
 
Bower & Grunt - A practical workflow
Bower & Grunt - A practical workflowBower & Grunt - A practical workflow
Bower & Grunt - A practical workflow
 
Once upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingOnce upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side rendering
 
Webpack and Web Performance Optimization
Webpack and Web Performance OptimizationWebpack and Web Performance Optimization
Webpack and Web Performance Optimization
 
Advanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsAdvanced front-end automation with npm scripts
Advanced front-end automation with npm scripts
 
Andrew Mykhaliuk - Sorry, I need to make a build for frontend
Andrew Mykhaliuk - Sorry, I need to make a build for frontendAndrew Mykhaliuk - Sorry, I need to make a build for frontend
Andrew Mykhaliuk - Sorry, I need to make a build for frontend
 
Grunt and Bower
Grunt and BowerGrunt and Bower
Grunt and Bower
 
Bundling your front-end with Webpack
Bundling your front-end with WebpackBundling your front-end with Webpack
Bundling your front-end with Webpack
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
 
Introduction to Express and Grunt
Introduction to Express and GruntIntroduction to Express and Grunt
Introduction to Express and Grunt
 
#2 Hanoi Magento Meetup - Part 2: Knockout JS
#2 Hanoi Magento Meetup - Part 2: Knockout JS#2 Hanoi Magento Meetup - Part 2: Knockout JS
#2 Hanoi Magento Meetup - Part 2: Knockout JS
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIWordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
 
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpOptimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
 
Angular2 ecosystem
Angular2 ecosystemAngular2 ecosystem
Angular2 ecosystem
 

Similar to Webpack: from 0 to 2

5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTYWilliam Chong
 
Multi modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.jsMulti modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.jsDavid Amend
 
DevHub 3 - Composer plus Magento
DevHub 3 - Composer plus MagentoDevHub 3 - Composer plus Magento
DevHub 3 - Composer plus MagentoMagento Dev
 
Maven 2.0 - Project management and comprehension tool
Maven 2.0 - Project management and comprehension toolMaven 2.0 - Project management and comprehension tool
Maven 2.0 - Project management and comprehension toolelliando dias
 
Alfresco DevCon 2018: SDK 3 Multi Module project using Nexus 3 for releases a...
Alfresco DevCon 2018: SDK 3 Multi Module project using Nexus 3 for releases a...Alfresco DevCon 2018: SDK 3 Multi Module project using Nexus 3 for releases a...
Alfresco DevCon 2018: SDK 3 Multi Module project using Nexus 3 for releases a...Martin Bergljung
 
Tribal Nova Docker feedback
Tribal Nova Docker feedbackTribal Nova Docker feedback
Tribal Nova Docker feedbackNicolas Degardin
 
Decrease build time and application size
Decrease build time and application sizeDecrease build time and application size
Decrease build time and application sizeKeval Patel
 
Hints and Tips for Modularizing Existing Enterprise Applications with OSGi - ...
Hints and Tips for Modularizing Existing Enterprise Applications with OSGi - ...Hints and Tips for Modularizing Existing Enterprise Applications with OSGi - ...
Hints and Tips for Modularizing Existing Enterprise Applications with OSGi - ...mfrancis
 
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
[Patel] SPFx: An ISV Insight into latest Microsoft's customization modelEuropean Collaboration Summit
 
Hints and Tips for Modularizing Existing Enterprise Applications (OSGi Commun...
Hints and Tips for Modularizing Existing Enterprise Applications (OSGi Commun...Hints and Tips for Modularizing Existing Enterprise Applications (OSGi Commun...
Hints and Tips for Modularizing Existing Enterprise Applications (OSGi Commun...Graham Charters
 
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)Chris O'Brien
 
Tutorial 1: Your First Science App - Araport Developer Workshop
Tutorial 1: Your First Science App - Araport Developer WorkshopTutorial 1: Your First Science App - Araport Developer Workshop
Tutorial 1: Your First Science App - Araport Developer WorkshopVivek Krishnakumar
 
Michal Havryluk: How To Speed Up Android Gradle Builds
Michal Havryluk: How To Speed Up Android Gradle BuildsMichal Havryluk: How To Speed Up Android Gradle Builds
Michal Havryluk: How To Speed Up Android Gradle Buildsmdevtalk
 
Create ReactJS Component & publish as npm package
Create ReactJS Component & publish as npm packageCreate ReactJS Component & publish as npm package
Create ReactJS Component & publish as npm packageAndrii Lundiak
 
Aleksandr Kutsan "Managing Dependencies in C++"
Aleksandr Kutsan "Managing Dependencies in C++"Aleksandr Kutsan "Managing Dependencies in C++"
Aleksandr Kutsan "Managing Dependencies in C++"LogeekNightUkraine
 

Similar to Webpack: from 0 to 2 (20)

Building JavaScript
Building JavaScriptBuilding JavaScript
Building JavaScript
 
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
 
Multi modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.jsMulti modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.js
 
DevHub 3 - Composer plus Magento
DevHub 3 - Composer plus MagentoDevHub 3 - Composer plus Magento
DevHub 3 - Composer plus Magento
 
GWT and PWA
GWT and PWAGWT and PWA
GWT and PWA
 
Maven 2.0 - Project management and comprehension tool
Maven 2.0 - Project management and comprehension toolMaven 2.0 - Project management and comprehension tool
Maven 2.0 - Project management and comprehension tool
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Alfresco DevCon 2018: SDK 3 Multi Module project using Nexus 3 for releases a...
Alfresco DevCon 2018: SDK 3 Multi Module project using Nexus 3 for releases a...Alfresco DevCon 2018: SDK 3 Multi Module project using Nexus 3 for releases a...
Alfresco DevCon 2018: SDK 3 Multi Module project using Nexus 3 for releases a...
 
Java User Group Cologne
Java User Group CologneJava User Group Cologne
Java User Group Cologne
 
Tribal Nova Docker feedback
Tribal Nova Docker feedbackTribal Nova Docker feedback
Tribal Nova Docker feedback
 
Decrease build time and application size
Decrease build time and application sizeDecrease build time and application size
Decrease build time and application size
 
Hints and Tips for Modularizing Existing Enterprise Applications with OSGi - ...
Hints and Tips for Modularizing Existing Enterprise Applications with OSGi - ...Hints and Tips for Modularizing Existing Enterprise Applications with OSGi - ...
Hints and Tips for Modularizing Existing Enterprise Applications with OSGi - ...
 
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
 
ESIGate dev meeting #4 21-11-2013
ESIGate dev meeting #4 21-11-2013ESIGate dev meeting #4 21-11-2013
ESIGate dev meeting #4 21-11-2013
 
Hints and Tips for Modularizing Existing Enterprise Applications (OSGi Commun...
Hints and Tips for Modularizing Existing Enterprise Applications (OSGi Commun...Hints and Tips for Modularizing Existing Enterprise Applications (OSGi Commun...
Hints and Tips for Modularizing Existing Enterprise Applications (OSGi Commun...
 
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
 
Tutorial 1: Your First Science App - Araport Developer Workshop
Tutorial 1: Your First Science App - Araport Developer WorkshopTutorial 1: Your First Science App - Araport Developer Workshop
Tutorial 1: Your First Science App - Araport Developer Workshop
 
Michal Havryluk: How To Speed Up Android Gradle Builds
Michal Havryluk: How To Speed Up Android Gradle BuildsMichal Havryluk: How To Speed Up Android Gradle Builds
Michal Havryluk: How To Speed Up Android Gradle Builds
 
Create ReactJS Component & publish as npm package
Create ReactJS Component & publish as npm packageCreate ReactJS Component & publish as npm package
Create ReactJS Component & publish as npm package
 
Aleksandr Kutsan "Managing Dependencies in C++"
Aleksandr Kutsan "Managing Dependencies in C++"Aleksandr Kutsan "Managing Dependencies in C++"
Aleksandr Kutsan "Managing Dependencies in C++"
 

Recently uploaded

SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 

Recently uploaded (20)

SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 

Webpack: from 0 to 2

  • 1. Webpack: from 0 to 2(.3.3) Milano_JS 04.04.2017
  • 2. Alessandro Bellini frontend developer @ Spryker - web: ilmente.com - github: github.com/ilmente - twitter: @ilmente
  • 3. Agenda - grunt, gulp and webpack - webpack modules - entry points - loaders and plugins - configuration - code overview - code splitting - code overview - tree shaking - code overview
  • 4. in the beginning it was grunt
  • 5. grunt - focus on configurations - built around a set of built-in commonly used tasks - extension using plugins - each plugin has its own custom configuration - every task is an array of different plugin configurations, that simply get executed one after another, in a strictly independent, and sequential fashion https://medium.com/@preslavrachev/gulp-vs-grunt-why-one-why-the-other-f5d3b398edc4
  • 7. gulp - focus on code - micro-tasks connected to each other (agnostic about their nature) - extension using plugins - plugins use API to be programmed - streams and pipelines https://medium.com/@preslavrachev/gulp-vs-grunt-why-one-why-the-other-f5d3b398edc4
  • 9. grunt - focus on configurations - built around a set of built-in commonly used tasks - extension using plugins - each plugin has its own custom configuration - every task is an array of different plugin configurations, that simply get executed one after another, in a strictly independent, and sequential fashion https://medium.com/@preslavrachev/gulp-vs-grunt-why-one-why-the-other-f5d3b398edc4
  • 10. grunt webpack - focus on configurations - built around a set of built-in commonly used tasks - extension using plugins - each plugin has its own custom configuration - every task is an array of different plugin configurations, that simply get executed one after another, in a strictly independent, and sequential fashion close, but it’s not exactly like this...
  • 11. grunt webpack - focus on configurations - built around a set of built-in commonly used tasks features - extension using plugins and loaders - each plugin/loader has its own custom configuration - every task compile process (or step) is an array of different plugin loaders (eventually configured/extend using plugins) configurations, that simply get executed one after another, in a strictly independent, and sequential fashion - loaders can be chained together: this is helpful for applying multiple transformations to a file in a pipeline https://webpack.github.io/docs/loaders.html (webpack 1.x docs)
  • 12. grunt - gulp - webpack - grunt and gulp are task runners - webpack is a module bundler - gulp and webpack are not necessary enemies You can use webpack with grunt/gulp: - https://webpack.js.org/guides/task-test-runner/ (almost useless page) - http://webpack.github.io/docs/usage-with-grunt.html - http://webpack.github.io/docs/usage-with-gulp.html
  • 13.
  • 15. modules - discrete chunk of functionality a program is broken into - abstraction - single responsability - reusability - better debugging and testing
  • 16. webpack modules - a dependency expressed by: - import (es2015) - require() (CommonJS) - define() and require() (AMD) - @import (css/sass/less) - url() (stylesheet) - <img src=””> (html) (!) Please refer to https://webpack.js.org/concepts: it’s well done and explained
  • 17. entry points the root of the tree
  • 18. - root of the tree
  • 19. loaders and plugins is this a kind of magic?
  • 20. loaders - functions - transform the source code of a module - synchronous or asynchronous - can be configured with options - can be chained - can emit additional arbitrary files https://webpack.js.org/concepts/loaders
  • 21. plugins - webpack backbone - “anything else that a loader cannot do” (cit.) - it’s wizardry - can you do everything? - may I have a coffee? - hooks into the whole webpack build system - allow you to access, change, extend any phase of the build process, from resolving a module to bundling the output https://webpack.github.io/docs/plugins.html
  • 22. in a nutshell - if you want to tell webpack how to load that specific type of resource: use loaders - everything else: use plugins
  • 23. in a nutshell - if you want to tell webpack how to load that specific type of resource: use loaders - everything else: use plugins - if you want to change how this module is resolved and compiled: use plugins
  • 24. a real configuration let’s switch to the code
  • 26. code splitting - it’s a features - split your code into various bundles - smaller bundle size - resource load prioritization control - on-demand loading - may have significant performance impact - on build/rebuild time - on application/site load time - you have the freedom to choose and implement your own strategy to optimise the assets management https://webpack.js.org/guides/code-splitting/
  • 27. - root of the tree
  • 28. code splitting superheroes - css - style-loader - ExtractTextWebpackPlugin - vendor - CommonsChunkPlugin - on-demand - import() - require.ensure() https://webpack.js.org/guides/code-splitting/
  • 29. tree shaking bullshit, myth or shut-up-and-take-my-money feature?
  • 30. tree shaking - positive selection of actual used code (live code) - in opposition to dead code removal (UglifyJs plugin) - introduced in bundlers world by github.com/rollup/rollup Known limitations for webpack: - static structure - relies on es2015 module import/export https://webpack.js.org/guides/tree-shaking
  • 31. the code said… - babel: - use preset babel-preset-es2015 with { “modules”: false } - use plugin babel-plugin-syntax-dynamic-import - limited to es2015 source code - unable to shake objects or inside statements - capable of dropping functions, but not classes - uglifyJS plugin needed