Fireship · @fireship

Module Bundlers Explained... Webpack, Rollup, Parcel, and Snowpack

Uploaded October 22, 2020 · Length 9:56

Module Bundlers Explained... Webpack, Rollup, Parcel, and Snowpack

Summary

This video explains how to use module bundlers like Webpack, Rollup, Parcel, and Snowpack to manage JavaScript dependencies in web applications.

  • module bundlers
  • webpack
  • rollup
  • parcel
  • snowpack
  • javascript dependencies
  • web development
  • front end development

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    to build a website you only need three

  2. 0:02

    ingredients html css and javascript

  3. 0:05

    that sounds pretty straightforward on

  4. 0:06

    the surface but here's the problem

  5. 0:08

    nobody just uses html css and javascript

  6. 0:11

    to build a website

  7. 0:12

    you might replace javascript with

  8. 0:13

    typescript then throw in a ui library

  9. 0:15

    like react

  10. 0:16

    to replace html you'll definitely need a

  11. 0:18

    css preprocessor like sas

  12. 0:20

    then you'll need to import a whole bunch

  13. 0:21

    of third-party modules so you're not

  14. 0:23

    doing everything from scratch many of

  15. 0:24

    your dependencies might use common js

  16. 0:26

    which isn't going to work with your

  17. 0:27

    modern es module syntax the code will

  18. 0:29

    have name collisions all over the place

  19. 0:31

    and even if you do manage to get it to

  20. 0:33

    work you'll likely end up with a massive

  21. 0:34

    javascript file which then needs to be

  22. 0:36

    minified

  23. 0:37

    and broken into smaller chunks just so

  24. 0:39

    people can visit your site with a

  25. 0:40

    reasonable load time you'll also need to

  26. 0:42

    create different versions of your

  27. 0:43

    javascript and load polyfills to ensure

  28. 0:45

    that your code works on legacy browsers

  29. 0:47

    as a developer it's like being asked to

  30. 0:48

    land on the moon with a lawn chair and

  31. 0:50

    some balloons tied to it

  32. 0:52

    it's truly the most annoying aspect of

  33. 0:53

    building a web application

  34. 0:55

    but thankfully we have module bundlers

  35. 0:56

    which make this entire process

  36. 0:58

    a little less annoying in today's video

  37. 1:00

    you'll learn everything you ever wanted

  38. 1:01

    to know about module bundlers

  39. 1:03

    like webpack roll up parcel and snowpack

  40. 1:05

    we'll primarily focus on webpack because

  41. 1:07

    it's the most popular

  42. 1:08

    but most of the core concepts that we'll

  43. 1:10

    look at apply to all of them but make

  44. 1:12

    sure to watch until the end when we look

  45. 1:13

    at snowpack

  46. 1:14

    because it uses a technique that is much

  47. 1:16

    different than the others and represents

  48. 1:18

    what i think will be the future of front

  49. 1:19

    end web development if you're new here

  50. 1:21

    like and subscribe and consider becoming

  51. 1:22

    a pro member at fireship io or sponsor

  52. 1:25

    me on github for even more content let's

  53. 1:27

    start by answering the question of what

  54. 1:28

    is a module bundler

  55. 1:30

    i already presented a long list of

  56. 1:31

    problems and the role of the module

  57. 1:33

    bundler is to fix these problems

  58. 1:35

    the most fundamental thing they do is

  59. 1:36

    take multiple javascript files

  60. 1:38

    and combine them into a single large

  61. 1:40

    file that can be then used in the

  62. 1:42

    browser to load your javascript app

  63. 1:44

    this file or the javascript bundle as

  64. 1:46

    it's called contains your source code

  65. 1:48

    along with any third-party dependencies

  66. 1:49

    that you've imported

  67. 1:50

    your dependencies also likely have their

  68. 1:52

    own dependencies that need to be

  69. 1:54

    imported

  70. 1:54

    a bundler like webpack creates a

  71. 1:56

    dependency graph to keep track of how to

  72. 1:58

    put everything together

  73. 1:59

    you just tell webpack where to find your