How Hot Module Replacement REALLY Works | JS Toolchain From Scratch

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ส.ค. 2024
  • 🎉 NEW book on tooling (build your own tools!) Coming 2024, register for updates): lachlan-miller...
    ⚠️ NOTE: I refer to HMR as Hot Module RELOAD - it's actually "Replacement", I had been saying in wrong for years.
    🐦 My Twitter: / lachlan19900
    ✏️ Diagram/notes from video: app.eraser.io/...
    🔨 I am building an entire JS toolchain from (mostly) scratch. In this video, we lay the foundations and build out a naive but simple and functional hot module replacement (HMR) implementation.
    Source: github.com/lmi...

ความคิดเห็น • 30

  • @LachlanMiller
    @LachlanMiller  4 หลายเดือนก่อน +3

    The R in HMR is for "replacement" - I say "reload" in this video (and have done so for years). Sorry about that 🤦‍♂ Enjoy!

  • @aaditolkar
    @aaditolkar 4 หลายเดือนก่อน +2

    Great series! It can be hard to understand how these tools work at a basic level but you made it very digestable!

    • @LachlanMiller
      @LachlanMiller  4 หลายเดือนก่อน

      Thank you - I am glad you are enjoying it!

  • @MrJloa
    @MrJloa 12 ชั่วโมงที่ผ่านมา

    25:40 the hardest part of this is implementing the actual real life hot.accept method. I know that u used a simplified example where u just rerender the component, but it real-life conditions it would be much harder (like how do restore the props state for the hot swapped component from the parent?)

  • @Kevin-xo5ul
    @Kevin-xo5ul 4 หลายเดือนก่อน +2

    This is something I've been wanting to look into for a while, so great timing on the video.

    • @LachlanMiller
      @LachlanMiller  4 หลายเดือนก่อน

      Hope you find it useful!

  • @TheAlexLichter
    @TheAlexLichter 4 หลายเดือนก่อน +4

    I was today years old that it is Replacement and not Reload 🙈
    Thanks for the video Lachlan 🙌🏻

    • @LachlanMiller
      @LachlanMiller  4 หลายเดือนก่อน +1

      Thanks! Been tuning in to you & Michael's podcast, great stuff! SSR / hydration isn't something I know well, might have to hit you up for some help when I get to making a video about how that works under the hood...

    • @TheAlexLichter
      @TheAlexLichter 4 หลายเดือนก่อน +1

      @@LachlanMiller Glad you enjoy the podcast ☺
      Oh yes, absolutely! My DMs are always open 🙌🏻

  • @rameshramesh-bd2wu
    @rameshramesh-bd2wu 4 หลายเดือนก่อน +1

    Awesome content, when can we expect your book ?

    • @LachlanMiller
      @LachlanMiller  4 หลายเดือนก่อน

      Hopefully later this year, this kind of content takes a ton of time! I will send out email updates as they come.

  • @josipbjezancevic5697
    @josipbjezancevic5697 3 หลายเดือนก่อน

    This is great, thanks!

  • @Mac501pl
    @Mac501pl 4 หลายเดือนก่อน +1

    Great video! Nice to know how things we take for granted actually work

  • @user-nw8we9ul5p
    @user-nw8we9ul5p หลายเดือนก่อน

    Great content. Thanks

  • @dimasheiko
    @dimasheiko 4 หลายเดือนก่อน

    great video! please keep this tooling series going 👏

  • @sravansuresh7460
    @sravansuresh7460 4 หลายเดือนก่อน +2

    This was awesome. Loving the series.

    • @LachlanMiller
      @LachlanMiller  4 หลายเดือนก่อน

      Thanks, glad you are enjoying it! Not sure what to focus on next, any recommendations?

    • @sravansuresh7460
      @sravansuresh7460 4 หลายเดือนก่อน +2

      @@LachlanMiller I have always been curious about source maps and how the browser uses them. I would also love to see a basic bundler & transpiler built with something like esbuild and what to keep in mind when working with them.

    • @LachlanMiller
      @LachlanMiller  4 หลายเดือนก่อน +1

      @@sravansuresh7460 Source maps for sure, to show this off I think we need a bundler / transpiler first, that might be next 🔥

  • @Pablitox26
    @Pablitox26 4 หลายเดือนก่อน

    This is amazing! Learned a lot, thanks so much!! 😃

  • @user-hi9it8pm4r
    @user-hi9it8pm4r 4 วันที่ผ่านมา

    cool and make sense

  • @alimaher1
    @alimaher1 หลายเดือนก่อน

    Came here after the beef between Evan You and the guy from TsCoding Haha. Really interesting stuff really. Great video! Thanks, man.

    • @LachlanMiller
      @LachlanMiller  หลายเดือนก่อน

      what beef?

    • @alimaher1
      @alimaher1 หลายเดือนก่อน

      @@LachlanMiller th-cam.com/video/96JvriLR4s8/w-d-xo.htmlsi=q9UEoAah88cwMcAl I mean this

  • @bk1507
    @bk1507 4 หลายเดือนก่อน +1

    im confused in the hotmodule class you have an accept method that takes in a callback. but then the accept method is not called anywhere so where is the callback coming from?

    • @LachlanMiller
      @LachlanMiller  4 หลายเดือนก่อน

      Confusing right... it is called in the `child,.js`, it is `import.meta.hot.accept(...)`. It is called as soon at the module is loaded. See here: github.com/lmiller1990/build-your-own-vite/blob/371c6a991615f881ac1562ebcbb2ffdf02fe9c6e/dev-server/src/child.js#L3

  • @metallust
    @metallust หลายเดือนก่อน

    Actual web development

  • @TourBD-53
    @TourBD-53 หลายเดือนก่อน

    Hello,
    I was analyzing your TH-cam channel. your you tube SEO score is zero.
    It should be increased. and subscribers ,views , like, comments is very low according
    to your channel age. This is why your you tube growth is very low and your channel
    setup is also having many problems. If, you can solve this problems your channel will
    grow and be famous very quickly.