Generic web component HMR
I'm messing around with a generic way to do hot-module-replacement with generic web components whether they be vanilla, or done in a framework like Polymer or Skate.
The idea is that you call
hmr(customElementConstructor) in your module files and it will set up the proper hooks.
const filename should be inserted at build time so that it can remember the original
localName of the component for the module.
WTF is "x-layout", "Layout" and "filename"
filenamerepresents the filename at build time. This should be replaced with that.
x-layoutjust a dummy filename I was using for testing.
Layouta constructor that I was testing.
Why not replace the node?
When you replace the node, you have to reconstruct it as it was before. If the original node was being interacted with, you'd lose UX state, even if it was restored back to its original internal state.
Why breadth-first traversal?
No reason yet. It doesn't appear, at this point, that it would make a difference at all since all replacements need to happen at some point.