max-mapper / yo-yo

A tiny library for building modular UI components using DOM diffing and ES6 tagged template literals
1.33k stars 65 forks source link

hot module reload : yoyo webpack #12

Open SilentCicero opened 8 years ago

SilentCicero commented 8 years ago

Anyone have any ideas about adding hot module reload for yoyo template objects?

My current incomplete code:

//   ./yoyo-hot-loader.js
module.exports = function(source) {
  if ((source.indexOf('yo`') > -1 || source.indexOf("yo-yo") > -1) && source.indexOf("module.hot") === -1) {
    source += "if(module.hot) {";
    source += "   module.hot.accept();";
    source += "}";

    return source;
  }

  return null;
}

I'm not to familiar with the webpack hot reload plugin. Currently, this does hot reload but does not remove the old code. Ideas?

Here is the API: https://webpack.github.io/docs/hot-module-replacement.html

yoshuawuyts commented 8 years ago

cc/ @shama - I reckon you might be the bestest person of us all to solve this, hah :sparkles: - I have no idea how to webpack

SilentCicero commented 8 years ago

@yoshuawuyts lolol. Oh god. Well it is a mess of a system, but powerful.

Really like yoyo, want to build with it. I have big plans for these little modules. And sheet-router is awesome =D

SilentCicero commented 8 years ago

This seems of use as well @shama https://github.com/just-boris/handlebars-hot-loader - fairly simple

SilentCicero commented 8 years ago

Also, this helps too: https://github.com/yargalot/Angular-HMR

shama commented 8 years ago

I haven't used yo-yo or bel with webpack yet but it should just work. When I get some time I'll play around with it a bit.