Re: [w3c/webcomponents] JavaScript bundlers, HMR and customElements.define() (#829)

Hi from the webpack team 👋. First of all: hats off to @kyr0 for this awesome PoC.

Using Proxies sounds perfectly fine to me. In fact, that's how most HMR implementations work (like https://github.com/gaearon/react-hot-loader). Not allowing to redefine the custom element makes perfectly sense from the browser's point of view.

Without having thought about all the small details, I would assume an HMR implementation to call the `disconnectedCallback` on the old component, remove all the markup from the DOM and then call manually the constructor and the `connectedCallback` on the new component. If the HMR implementation knows that it can't replace the web component, it's ok to reject the update and trigger a hard reload.

I also think that it's safe to assume that the developer did not do anything weird. Unlike CSS, it's impossible to do safe HMR with arbitrary JavaScript. It's ok to make HMR work in 90% cases. When in doubt, most developers will hit reload anyway.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/829#issuecomment-550437333

Received on Wednesday, 6 November 2019 18:21:01 UTC