Fireship · @fireship

Vite in 100 Seconds

Uploaded February 23, 2022 · Length 2:29

Vite in 100 Seconds

Summary

veet simplifies front-end web app development with instant code loading and hot module replacement.

  • veet
  • javascript build tool
  • front-end development
  • instant code loading
  • hot module replacement

Transcript preview

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

  1. 0:00

    veet a javascript build tool that

  2. 0:02

    simplifies the way we build and develop

  3. 0:04

    front-end web applications at its core

  4. 0:06

    it does two things one serve your code

  5. 0:08

    locally during development and two

  6. 0:10

    bundle your javascript css and other

  7. 0:12

    assets together for production there are

  8. 0:14

    many other tools out there that do the

  9. 0:16

    same thing like webpack so what makes

  10. 0:18

    vee different well it was created by

  11. 0:20

    evan yu who also created vue.js as a way

  12. 0:22

    to both simplify and speed up the build

  13. 0:24

    process not long ago web developers had

  14. 0:27

    no native way to combine javascript

  15. 0:28

    files together in a modular way this led

  16. 0:31

    to tools like webpack and rollup that

  17. 0:33

    concatenate multiple files together into

  18. 0:35

    a single bundle for the browser the

  19. 0:37

    problem is that this process becomes

  20. 0:38

    increasingly slow as the app adds more

  21. 0:40

    code and dependencies in 2015 ecmascript

  22. 0:43

    modules were introduced and by 2020 had

  23. 0:45

    wide browser support allowing developers

  24. 0:47

    to import and export code from different

  25. 0:50

    files in the browser veed leverages

  26. 0:52

    native es modules in the browser to load

  27. 0:54

    your code instantly no matter how large

  28. 0:56

    the app is it also supports hot module

  29. 0:58

    replacement for an extremely fast

  30. 0:59

    feedback loop during development when

  31. 1:01

    building for production it uses roll up

  32. 1:03

    under the hood so you don't have to

  33. 1:04

    worry about configuring it it's an

  34. 1:06

    opinionated tool that provides

  35. 1:07

    conventions that work out of the box for

  36. 1:09

    the majority of developers to get

  37. 1:10

    started run npm netweat from the command

  38. 1:13

    line and choose a starter project with

  39. 1:14

    your favorite front-end framework you'll

  40. 1:16

    notice the project comes with a v-config

  41. 1:18

    file it has a plug-in ecosystem that can

  42. 1:20

    extend it with additional features and

  43. 1:22

    you can also manually override the

  44. 1:24

    roll-up defaults when necessary and

  45. 1:25

    there are some really cool plugins out

  46. 1:27

    there like vtssr that can do server-side

  47. 1:29

    rendering like next.js now to serve the

  48. 1:31

    application locally run npm run dev even

  49. 1:34

    if i install a bunch of big dependencies

  50. 1:36

    like low dash and moment the time to run

  51. 1:38

    the dev server does not change now if

  52. 1:39

    you open the network tab in the browser

  53. 1:41

    dev tools you'll notice that instead of

  54. 1:42

    importing a single javascript bundle

  55. 1:44

    file it's importing our actual source

  56. 1:46

    code like a raw tsx file in this case it

  57. 1:49

    also makes typescript about 20 to 30

  58. 1:51

    times faster because it skips type

  59. 1:52

    checking and uses es build to transpile

  60. 1:55

    your code now as you're developing your

  61. 1:56

    app you might change the state of it in

  62. 1:58

    the ui then realize that some of the

  63. 1:59

    code needs to change when you modify the