Open Bockit opened 8 years ago
Hi, I have the same problem, it took me hours to find out what was wrong, and it turned out to be the same problem you have, if I don't use hmr
, everything works as expected. I see this has been flagged over a year ago, did you find a workaround it?
a workaround this would be to use browserify global
, so instead of exporting functions this way
// watchify -p browserify-hmr ... --standalone myapp
export function initActions() {}
export function initForms() {}
use global
this way
// watchify -p browserify-hmr ...
var myapp = global.myapp || {};
myapp.initActions = function() {};
myapp.initForms = function() {};
global.myapp = myapp;
make sure that functions and variables in myapp
don't get redefine in different files.
I hope in the future I can have sometime to fix this behavior in browserify-hmr
. Meanwhile I love browserify-hmr
:)
I use browserify with the standalone option to avoid having to store initial state data on the
window
object in my universal apps.I have found that adding the hmr plugin breaks the standalone option, though I have been unable to determine why. Reproduction:
package.json
index.js
index.html
If you run
npm run bundle-no-hmr
and serve this folder up and visit index.html, you'll seeFoo
in the console.If you run
npm run bundle
, close once the bundling is complete and serve this folder up and visit index.html, you'll seeLog
is not a function in the console. It's actually an empty object{}
Thanks for your time.