Lachlan Miller
Lachlan Miller
  • 174
  • 457 164
How Hot Module Replacement REALLY Works | JS Toolchain From Scratch
🎉 NEW book on tooling (build your own tools!) Coming 2024, register for updates): lachlan-miller.ck.page/92dfa021b3
⚠️ 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/workspace/W1ZOWqpCPrv4Vz2vcytS?origin=share
🔨 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/lmiller1990/build-your-own-vite/tree/main
zhlédnutí: 3 313

Video

Visual Guide to the Modern Frontend Toolchain (Vite)
zhlédnutí 79KPřed 5 měsíci
🎉 NEW book on tooling (build your own tools!) Coming 2024, register for updates): lachlan-miller.ck.page/92dfa021b3 🐦 My Twitter: Lachlan19900 ✏️ Diagram/notes from video: app.eraser.io/workspace/1CfLxNLf9DY9E9Ndesq4?origin=share I talk about Vite, the best toolchain for building frontend apps right now, which combines a number of other tools under the hood with with some extra good...
How To Debug Infuriating Module Errors
zhlédnutí 909Před 5 měsíci
🎉 NEW book (coming 2024, register for updates): lachlan-miller.ck.page/92dfa021b3 📗 Current Book (Vue, Updated Aug 2023): lachlanmiller.gumroad.com/l/vuejs-design-patterns 🐦 My Twitter: Lachlan19900 🧠 Useful Links - Why you should ALWAYS use an extension: lachlan-miller.me/articles/why-you-should-always-use-an-extension-for-javascript-files - Node's creator regrets about module exte...
Vue's New Rendering Strategy (Vapor), Innovation vs Maintenance
zhlédnutí 6KPřed 6 měsíci
🎉 NEW book (coming 2024): lachlan-miller.ck.page/92dfa021b3 📗 Book (Vue, Updated Aug 2023): lachlanmiller.gumroad.com/l/vuejs-design-patterns 🐦 My Twitter: Lachlan19900 Today I talk about Vue's new rendering stategy, Vapor mode, performance, and more broadly the implications of innovation vs maintenance in the JS community. 🧠 References: - github.com/sveltejs/svelte/issues/2546 - va...
My Favorite TypeScript Tips and Tricks
zhlédnutí 6KPřed 6 měsíci
🎉 Writing a book about tooling, testing and development philosophy: lachlan-miller.ck.page/92dfa021b3 📗 Book (Vue, Updated Aug 2023): lachlanmiller.gumroad.com/l/vuejs-design-patterns Type Challenges to learn and push yourself github.com/type-challenges/type-challenges 🐦 My Twitter: Lachlan19900 Some neat TypeScript tips and tricks I've learned over the years. Now you know them, too!
3 Ways to Avoid Prop Drilling in Vue/React
zhlédnutí 4,4KPřed 6 měsíci
📗 Book (Updated Aug 2023): lachlanmiller.gumroad.com/l/vuejs-design-patterns 🎉 Writing a book about tooling, testing and development philosophy: lachlan-miller.ck.page/92dfa021b3 🐦 Twitter: Lachlan19900 Sick of passing props to deeply nested components? Here's a few alternatives I've used over the years, with my thoughts and recommendations.
Form Validation Strategies for JavaScript Apps
zhlédnutí 1,2KPřed 6 měsíci
📗 Book (Updated Aug 2023): lachlanmiller.gumroad.com/l/vuejs-design-patterns 🎉 Writing a book about tooling, testing and development philosophy: lachlan-miller.ck.page/92dfa021b3 🐦 Twitter: Lachlan19900 Some different approaches to validating forms I've seen over the years with my thoughts.
The Mighty Deferred Promise - An Interview Recount
zhlédnutí 8KPřed 8 měsíci
❗️ See the comments - I over-engineered this, my solution is far from ideal. Good discussion in comments! 👉 I am writing a book on tooling! Check it out: lachlan-miller.ck.page/92dfa021b3 🐦 Lachlan19900 I had an interview recently which featured an interesting question. In this video, I share the question and my solution, along with a construct, the mighty deferred promise. There's ...
Patterns for Error Handling
zhlédnutí 1,9KPřed 8 měsíci
👉 I am writing a book! Check it out: lachlan-miller.ck.page/92dfa021b3 📗Book on Design Patterns: lachlanmiller.gumroad.com/l/vuejs-design-patterns 🐦 Lachlan19900 In this video, I share some thoughts and techniques about error handling in a little application I'm working on.
The Difference Between Vue and React
zhlédnutí 33KPřed 10 měsíci
📗 Book (Updated Aug 2023): lachlanmiller.gumroad.com/l/vuejs-design-patterns 🐦 Twitter: Lachlan19900 Today I talk about the philosophical difference between Vue and React and how it impacts the reactivity system of the two frameworks.
Renderless Component & Type Safety (Advent of Vue #17)
zhlédnutí 1,2KPřed rokem
My solution to the 17th and final Advent of Vue challenge! Good one to end on - renderless components are a great example of separation of concerns. We also talk about pushing logic out of a component into a stateless function. I also talk about renderless components in my book: lachlan-miller.me/design-patterns-for-vuejs 👉 Link to algorithm www.movable-type.co.uk/scripts/latlong.html 👉 Haversi...
Type Safe Custom Directives (Advent of Vue #16)
zhlédnutí 627Před rokem
My solution to the 16th Advent of Vue challenge! Pretty quick one, and something that doesn't get as much attention as it probably deserves - custom directives. 🎄 Advent of Vue: adventofvue.com/ 💻 Code: github.com/lmiller1990/aov2022/tree/christmas-done 🐦 Keep up with me on Twitter! Lachlan19900 If you like my teaching style, I have a book and two courses! 👀 (Book) Design Patterns f...
Shuffling Arrays and a Map Trick (Advent of Vue #14)
zhlédnutí 556Před rokem
My solution to the 14th Advent of Vue challenge! New favorite - we get to talk about shuffling algorithms and the the jankiness of Array.prototype.sort. 👉 Fisher Yates Shuffle: en.wikipedia.org/wiki/Fisher–Yates_shuffle 🎄 Advent of Vue: adventofvue.com/ 💻 Code: github.com/lmiller1990/aov2022/tree/14-done 🐦 Keep up with me on Twitter! Lachlan19900 If you like my teaching style, I hav...
Solving a 2000 Year Old Problem with TDD and Vue (Advent of Vue #12)
zhlédnutí 583Před rokem
My solution to the 12th Advent of Vue challenge! This was my favorite one so far! Explaining this in a short video while coding was difficult, I hope it's not too difficult too confusing 🤯 👉 Numberphile on Josephus Problem czcams.com/video/uCsD3ZGzMgE/video.html 🎄 Advent of Vue: adventofvue.com/ 💻 Code: github.com/lmiller1990/aov2022/tree/aov-12-josephus 🐦 Keep up with me on Twitter! twitter.co...
Arbitrary Values & Properties in Tailwind (Advent of Vue #11)
zhlédnutí 608Před rokem
My solution to the 11th Advent of Vue challenge! Some neat Tailwind tips and tricks. 🎄 Advent of Vue: adventofvue.com/ 💻 Code: github.com/lmiller1990/aov2022/tree/aoc-11-twinkle-solution 🐦 Keep up with me on Twitter! Lachlan19900 If you like my teaching style, I have a book and two courses! 👀 (Book) Design Patterns for Vue.js: lachlan-miller.me/design-patterns-for-vuejs (YT_5_OFF fo...
TDD, TypeScript Tricks and Sorting (Advent of Vue #9)
zhlédnutí 1,7KPřed rokem
TDD, TypeScript Tricks and Sorting (Advent of Vue #9)
Vue i18n & Locales (Advent of Vue #8)
zhlédnutí 4,3KPřed rokem
Vue i18n & Locales (Advent of Vue #8)
Composables and Functional Logic (Advent of Vue #6)
zhlédnutí 1,8KPřed rokem
Composables and Functional Logic (Advent of Vue #6)
For Loops? Recursion? (Advent of Vue #4)
zhlédnutí 1,1KPřed rokem
For Loops? Recursion? (Advent of Vue #4)
Simple Functions and Conditionals (Advent of Vue #2)
zhlédnutí 800Před rokem
Simple Functions and Conditionals (Advent of Vue #2)
Fetching and Debounce in Vue (Advent of Vue #1)
zhlédnutí 2,3KPřed rokem
Fetching and Debounce in Vue (Advent of Vue #1)
Pushing Logic into Composables
zhlédnutí 1,7KPřed rokem
Pushing Logic into Composables
Cypress CT 5/8 - Asserting Again Emitted Events
zhlédnutí 590Před rokem
Cypress CT 5/8 - Asserting Again Emitted Events
Cypress CT 3/8 - Building a Better Mount
zhlédnutí 714Před rokem
Cypress CT 3/8 - Building a Better Mount
Cypress CT 1/8 - Diving in the Deep End with Cypress Component Testing
zhlédnutí 4,7KPřed rokem
Cypress CT 1/8 - Diving in the Deep End with Cypress Component Testing
Cypress CT 8/8 - Better Type Safety, cy.mount & CT at Cypress
zhlédnutí 424Před rokem
Cypress CT 8/8 - Better Type Safety, cy.mount & CT at Cypress
Cypress CT 2/8 - A Useful Pattern for Wrapping Components
zhlédnutí 1,4KPřed rokem
Cypress CT 2/8 - A Useful Pattern for Wrapping Components
Cypress CT 6/8 - Forms & Intercepting Requests
zhlédnutí 428Před rokem
Cypress CT 6/8 - Forms & Intercepting Requests
Cypress CT 7/8 - A Suspenseful Test
zhlédnutí 287Před rokem
Cypress CT 7/8 - A Suspenseful Test
Cypress CT 4/8 - The Seam Between CT & E2E Tests
zhlédnutí 464Před rokem
Cypress CT 4/8 - The Seam Between CT & E2E Tests

Komentáře

  • @dimis7096
    @dimis7096 Před dnem

    oh my god friend you will never believe how useful this video was for me and how many concepts you helped me to grasp ! Thank you very much , i love you i wish you the best <3

  • @gdifrancesco
    @gdifrancesco Před 4 dny

    First of all, great video! I was struggling to find some good comparison as you did, nice job! At 9:26, actually the whole React JSX gets rerendered. That's how React works: whenever a state (useState) changes, the whole function will be executed, including the render/JSX. There are no exceptions on this. There are no actual "dependencies" for the JSX render, it's just about the state changes. It's behind the scenes that React decides whether a node should be "committed" to the DOM, i.e. change the actual DOM nodes: this phase is called "Commit", and it's the last one of the whole rendering process. But this is something we shouldn't care much about as devs, we just have to know that the whole function/component gets re-executed and re-rendered. When you "opt-out" a variable from the reactivity as you said, it just ensures it remains the same (not reassigned, meaning the function inside useMemo is not called) unless an element in the dep array changes (strict equal ===). This is just about expensive computations of that specific variable, therefore it's quite rare to use. Anyway, I loved how deep you dived into these things, which could open up a lot of thoughts into various aspects of both tools. Thanks for the video!

    • @LachlanMiller
      @LachlanMiller Před 2 dny

      thanks for the kind words! sounds like you have a great understanding of this now. worth considering that apparently React has a compiler that changes how rendering works - I'd recommend checking that out to see what's the latest developments in that area.

  • @cariyaputta
    @cariyaputta Před 11 dny

    Thanks. Quality explanation.

  • @marknielsen4494
    @marknielsen4494 Před 11 dny

    Excellent

  • @malcolmvernon6808
    @malcolmvernon6808 Před 13 dny

    typescript already gives you warnings if you try to edit a const array or object litteral

    • @LachlanMiller
      @LachlanMiller Před 12 dny

      Did not realize this - which tip are you referring to w/ this comment specifically?

    • @malcolmvernon6808
      @malcolmvernon6808 Před 11 dny

      @@LachlanMiller In close to the beginning of the video you said to mark const variables "as const" in typescript (first tip actually). And I thought "wow what a cool trick" and then I did an experiment with it and then I was like - WAIT A MIN - typescript already does this out the box without needing to add as const to it. I'm not sure if maybe older typscript versions didn't do that. I tried it mutating both const array and const object litterals and it all gives red warning underlines for it out the box with my tsx files if you try to mutate them

    • @LachlanMiller
      @LachlanMiller Před 11 dny

      @@malcolmvernon6808 I think older versions of TS did not do this, glad it's getting stricter

  • @TourBD-53
    @TourBD-53 Před 14 dny

    Hello, I was analyzing your CZcams 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.

  • @micahtonning7967
    @micahtonning7967 Před 16 dny

    Thank you for creating this video. It was extremely helpful.

  • @menglin7432
    @menglin7432 Před 17 dny

    Now this is something I'd highly recommend any JS developer to watch

  • @user-nw8we9ul5p
    @user-nw8we9ul5p Před 18 dny

    Great content. Thanks

  • @AkshyatChapagain
    @AkshyatChapagain Před 18 dny

    Just amazing, every new person getting into web dev should watch this video. I can't believe you don't have more subscribers.

  • @sangramdesai4295
    @sangramdesai4295 Před 19 dny

    Nice explanation! I loved how you compared Vue.js and React. Please post a new video explaining how code is compiled in both frameworks step by step

  • @dimitriborgers9800
    @dimitriborgers9800 Před 21 dnem

    One question: if webpack bundles everything (including third party modules) into bundle.js, doesn't that ever get too big for the browser? The Gatsby library has 1200+ modules; I would assume the bundle.js would be absolutely massive.

    • @LachlanMiller
      @LachlanMiller Před 20 dny

      You can load modules async, so the initial bundle isn't huge. But yes, some libs have really huge bundles - I do not think there is any upper limit, I have worked on apps with 20mb of JS. This takes a long time to parse in the browser. Things like gzip, minify, etc can make it a lot smaller.

  • @alimaher1
    @alimaher1 Před 22 dny

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

    • @LachlanMiller
      @LachlanMiller Před 21 dnem

      what beef?

    • @alimaher1
      @alimaher1 Před 21 dnem

      @@LachlanMiller czcams.com/video/96JvriLR4s8/video.htmlsi=q9UEoAah88cwMcAl I mean this

  • @dimitriborgers9800
    @dimitriborgers9800 Před 22 dny

    This is a phenomenal video, thank you!

  • @KousayJebir
    @KousayJebir Před 24 dny

    awesome video man ! i do have a quick question tho , when you reached the part of using react and imported React from 'react' what tool was responsible to resolve the location of 'react' or to be more precise the actual location of the file that contains the React object

    • @LachlanMiller
      @LachlanMiller Před 23 dny

      Whatever runtime you are using will resolve modules using its own pre-determined rules. In this video the runtime is Node.js. You can google "node.js module resolution algorithm" or read here. nodejs.org/api/modules.html#loading-from-node_modules-folders In Node.js if the import is not a relative path, it will look in `node_modules` and then find the `package.json` for the module. In there it looks at specific fields like "main", etc.

    • @KousayJebir
      @KousayJebir Před 18 dny

      @@LachlanMiller thank you very much

  • @f_48irfanshaikh29
    @f_48irfanshaikh29 Před 24 dny

    Actual web development

  • @DmitriiBaranov-ib3kf
    @DmitriiBaranov-ib3kf Před 26 dny

    At least four new allocations on every count update in this React component. And zero in Vue

    • @LachlanMiller
      @LachlanMiller Před 26 dny

      No doubt there is room for optimisation, just an example to illustrate the difference in reactivity systems!

    • @DmitriiBaranov-ib3kf
      @DmitriiBaranov-ib3kf Před 22 dny

      @@LachlanMiller I agree, but there seems to be no room for optimization for Vue reactivity system. Besides, React won't go to this optimization room, so to say, since it'd be a whole paradigm shift. React is based on a flawed immutability-first approach, which causes tons of allocations and loops (both in spreads and dependency array comparisons)

  • @Ayvengo21
    @Ayvengo21 Před 27 dny

    It's a bit unclear and i haven't see some good explanation how does vue know that there was a change in some of the ref variables. Like is it some setInterval that check it or some hidden setter function?

    • @LachlanMiller
      @LachlanMiller Před 26 dny

      It creates a map of all dependencies for each reactive effect. See czcams.com/video/HzhcXVFEiVY/video.html or lachlan-miller.me/articles/vue-3-reactivity-from-scratch

  • @vitaliyd23
    @vitaliyd23 Před měsícem

    What a gem! Love that you included the error solving parts and the "single take" nature of the video. Liked, subscribed, and added to a playlist)

  • @handmadegamesdev
    @handmadegamesdev Před měsícem

    Great video. This is exactly the type of breakdown I was looking for.

  • @oussamareghay7081
    @oussamareghay7081 Před měsícem

    Thanks a lot fo the tutorial !

  • @atlantic_love
    @atlantic_love Před měsícem

    For the Vue side, it appears to me that you have a function called watchEffect, but when the button is clicked it is calling a function named onClick. I don't understand this.

  • @chiemekae718
    @chiemekae718 Před měsícem

    you got a subscriber here

  • @chiemekae718
    @chiemekae718 Před měsícem

    excellent resources alway hard to show up on searches on CZcams. You are Amazing mate

  • @rioredwards
    @rioredwards Před měsícem

    This was awesome! Thank you for making this!

  • @deveshprasad6418
    @deveshprasad6418 Před měsícem

    This is amazing. You're a genius. You made it so easy to understand.

  • @basarat
    @basarat Před měsícem

    Great vid as always 🌹 Wonder if the vue code is valid 🤔 click=onClick …. Fn click=onClick2() …. Value,Void,undefined If it’s invalid, sad that vue doesn’t give an error despite being ts. Might be a big reason why enterprise would choose react 🤷🏻‍♂️

  • @alexanderzin
    @alexanderzin Před měsícem

    This is gold

  • @kerimzunic
    @kerimzunic Před měsícem

    I'm glad this video exists

    • @LachlanMiller
      @LachlanMiller Před měsícem

      thanks I am glad you exist and watched it!

  • @basarat
    @basarat Před měsícem

    Nice video ❤ However you don’t need a deferred promise for this. I’ll be happy to edit the code for you if you post a gist 🌹🫰🏻

    • @LachlanMiller
      @LachlanMiller Před měsícem

      Heya, thanks for the comment, we discussed this already in the pinned comment

    • @basarat
      @basarat Před měsícem

      @@LachlanMiller I see it now, Perfect 🌹

  • @mlv60
    @mlv60 Před 2 měsíci

    0:47 not very important but potentially good habit/convention for both readability (separation of concerns) and consistency with vue's approach: you can extract the anonymous function from the jsx into an appropriately named const and then just simply pass it in the jsx event. this way any changes you make to the logic will be done in the logic part of the code (just like in vue) and if you are writing a more complex function it would look ugly and clutter the jsx. this way, simple or complex, your logic consistently shows up where its expected and you and your team will frown less :] edit: the reason i mention consistency with vue is that its easier to switch or be good at both the more similar they are, in general

  • @JulienMayer-fh7wj
    @JulienMayer-fh7wj Před 2 měsíci

    Great video but I think your explanation at 9:40 may cause someone to think React does not return "new" JSX

  • @sourabhajoshi2129
    @sourabhajoshi2129 Před 2 měsíci

    Hello Miller. Really am v happy from your channel. can you please make one medium TDD application? OR If you have means, can you share it with me ?

    • @LachlanMiller
      @LachlanMiller Před 2 měsíci

      hi, are you asking for an example project with lots of tests? Are you looking for Test Utils specifically?

    • @sourabhajoshi2129
      @sourabhajoshi2129 Před 2 měsíci

      @@LachlanMiller yes. Am looking for project with all test cases

    • @LachlanMiller
      @LachlanMiller Před 2 měsíci

      This one has some, check it out github.com/lmiller1990/vuejs-composition-api-course/tree/main/tests/unit

    • @sourabhajoshi2129
      @sourabhajoshi2129 Před 2 měsíci

      @@LachlanMiller Thank you v much 😍

  • @sourabhajoshi2129
    @sourabhajoshi2129 Před 2 měsíci

    Really very nice.. Thank you so much miller 🥰

  • @StandardLoop
    @StandardLoop Před 2 měsíci

    Really great video

  • @avimonnudash1762
    @avimonnudash1762 Před 2 měsíci

    Beautiful

  • @mxsniper223
    @mxsniper223 Před 2 měsíci

    thanks' a lot man <3

  • @pisyaone6635
    @pisyaone6635 Před 2 měsíci

    How are you managing to run Vue and React at the same time? Are you utilizing micro-frontend technology on this example?

    • @LachlanMiller
      @LachlanMiller Před 2 měsíci

      No, I just import them both and mount the apps on different DOM elements. Eg <div><div id='react' /><div id='vue' /></div>

  • @shinobi1975
    @shinobi1975 Před 2 měsíci

    Finally someone that explains the problem that is being solved by these stupid installs lol. 10/10 vid.

  • @josipbjezancevic5697
    @josipbjezancevic5697 Před 2 měsíci

    This is great, thanks!

  • @FavourAkpasi
    @FavourAkpasi Před 2 měsíci

    a lot of react slander on the CS. i am still a react fan. but this video is a good comparison between both.

  • @oleksandraokhotnykova8672
    @oleksandraokhotnykova8672 Před 2 měsíci

    "We're not sane, we're INSANE, we're modern web developers" LMAOOO

  • @Manoj-qf6lq
    @Manoj-qf6lq Před 2 měsíci

  • @ohsimtabem
    @ohsimtabem Před 2 měsíci

    Nice overview, as always! I'm doing a refactor of a legacy Rails app form to Vue and we have a mix of "Server config driven" + "Reward Early". We didn't want to discard the existing base field "rules schema" coming from the backend but, at the same time, we want to improve UX as the form is very complex/big/stepped. From my experience, the major problem with the "Server config driven" was dynamic/conditional field validation: a "field B" is required only if "field A" has a certain value. This led to duplication on the front end as we didn't find any good solution to share those rules and is indeed a source of bugs/inconsistencies. In some cases where the validation logic was so complex, we drop the client-side validation of that field and render the error only after validating on the server, so it is more of a hybrid approach! Thanks for another insightful video! Keep it up!

    • @LachlanMiller
      @LachlanMiller Před 2 měsíci

      I hadn't thought of the related field validation - eg only require field A when field B is checked, or something. Thanks for the comment, very insightful. Why are forms still so tedious in 2024 🤯

  • @Ari-lv8nc
    @Ari-lv8nc Před 2 měsíci

    why god , why

  • @kevinisaac4958
    @kevinisaac4958 Před 2 měsíci

    You've got my subscribe. More videos like this please!

  • @mahadyounis8734
    @mahadyounis8734 Před 2 měsíci

    Great

  • @adriatic123
    @adriatic123 Před 2 měsíci

    Another useless feature. Vue project built 2 years ago is totally obsolete and doesnt work anymore. Talk about reliability, total failure. Next please

    • @LachlanMiller
      @LachlanMiller Před 2 měsíci

      Code doesn't just stop working - unless the environment changed, it should be fine. Docker solves this problem! What is the issue, I might be able to help you debug?

  • @serhiicho
    @serhiicho Před 2 měsíci

    Good explanation! Thanks

  • @dontry1812
    @dontry1812 Před 2 měsíci

    Great stuff. I am starting to hook on Vite. One important thing I hope Vite had out of box is Module Federation, which is quite essential to build micro-frontend. Do you have any idea how to build micro-frontend with Vite?

    • @LachlanMiller
      @LachlanMiller Před 2 měsíci

      Not sure about micro frontends! I have not worked with those before. Let me know iff you find out!