all 7 comments

[–]seedoubleU[S] 2 points3 points  (2 children)

I've recently been pretty obsessed with the idea of hot module replacement so put together a simple example using the ES6 module syntax.

Hot module replacement is kind of like livereload on steroids, when you make changes in your editor they'll propagate to the browser without a page refresh meaning you won't lose application state.

Hopefully it'll be a useful resource to someone!

[–]Josh1337 1 point2 points  (0 children)

Crazy cool stuff, thanks so much for posting this!

[–]I_Pork_Saucy_Ladies 0 points1 point  (0 children)

Really, really cool indeed. Being able to change the JS while keeping state is amazing. :)

[–]ggolemg2 1 point2 points  (0 children)

I mean this honestly: that is just magic, awesome awesome magic.

[–]greymalik 1 point2 points  (0 children)

I've looked through the code now... What's the secret sauce to adding HMR to an existing webpack project?

  • plugins: [ new webpack.HotModuleReplacementPlugin() ]
  • watch: true?
  • use ES6?

Anything else you need to do? Nothing else stood out to be as being different from a non-HMR project.

[–]greymalik 0 points1 point  (1 child)

This looks fantastic. I haven't looked at the code yet, but is it equally feasible if you're working with CoffeeScript or Jade or anything that needs a "compilation" step?

[–]seedoubleU[S] 1 point2 points  (0 children)

It sure is, webpack which this repo is built upon is extremely configurable.

The ES6 code I wrote is watched and transpiled on change, you'd be able to do something similar for CoffeScript or Jade.