browserify / browserify-handbook

how to build modular applications with browserify
Other
4.58k stars 292 forks source link

Fix Browserify-HMR example #59

Closed Macil closed 9 years ago

Macil commented 9 years ago

The current Browserify-HMR example relies on a bug in Browserify-HMR. The plugin shouldn't do anything for code that never calls module.hot.accept but it currently has a bug that would cause the example to work. Sorry about that!

The example using ud.defn works because that function calls module.hot.accept, but the use of ud.defn is superfluous because there's no need to update the pre-existing render function. The new execution of the module executes its own new render function. No reference to the older version of the render function is kept around. (If the render function was exported, then ud.defn would be useful in order to update the old render function that other modules have already imported.) I need to work on the documentation around ud more. I don't think it should be in brief HMR examples like here.

I also added a mention of react-hot-transform and described how it was different from livereactload immediately before it.