liveBook · Manning

Hot module replacement

As explained in Web Component Development with Modern Libraries and Tooling

Hot module replacement is a development technique that updates changed modules in a running application without performing a full page refresh.

Hot module replacement (HMR) updates a running browser page when you save a source file it uses. Unlike a full page refresh, the update preserves page state, making it easier to keep working where you left off. section 2.2

A component development loop

A wrec project can display a `<hello-world>` component defined in `hello-world.ts`. Run the project with Vite using `npm run dev`, then save a source change and see the affected page update automatically. Vite is recommended for wrec projects, but it is not required. section 8.2

HMR is a development-server feature, not a requirement of web components or a particular component library. Vite provides it for projects using vanilla web components or Lit; Stencil projects support HMR without using Vite. These setup examples describe what HMR does, not how its module updates work internally. section 3.5 section 6.2

How Web Component Development with Modern Libraries and Tooling covers it

How deep it goes
Defines the visible behavior and gives project setup steps, but does not explain module-update internals.
Examples
Uses Vite development scripts and a wrec `<hello-world>` component as concrete project artifacts.
What it assumes
Assumes Node.js is installed while showing how to create an npm project and install Vite.
What you can do after
Operate/configure it with Vite’s `dev` script and recognize that Stencil supports it without Vite.
How it connects
Connects HMR to Vite, web components, ECMAScript modules, Lit, and Stencil.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Component Development with Modern Libraries and Tooling. The section links point to the parts of the book it draws on.