Macil / browserify-hmr

Hot Module Replacement plugin for Browserify
MIT License
373 stars 26 forks source link

Update broke my workflow #8

Closed serapath closed 8 years ago

serapath commented 8 years ago
  "scripts": {
    "watch": "watchify source/index.js -p [ browserify-hmr -u http://$(my-local-ip):3123 ] -p ghostmodeify -t babelify -o public/browser/bundle.js -dv"
  },
  "devDependencies": {
    "babelify": "^6.3.0",
    "browserify": "^11.2.0",
    "browserify-hmr": "^0.2.2",
    "ecstatic": "^1.1.3",
    "ghostmodeify": "^0.1.1",
    "my-local-ip": "^1.0.0",
    "watchify": "^3.4.0"
  }

npm run watch worked, but after upgrading from 0.2.2 to 0.3.1

  "scripts": {
    "watch": "watchify source/index.js -p [ browserify-hmr -u http://$(my-local-ip):3123 ] -p ghostmodeify -t babelify -o public/browser/bundle.js -dv"
  },
  "devDependencies": {
    "babelify": "^6.3.0",
    "browserify": "^11.2.0",
    "browserify-hmr": "^0.3.1",
    "ecstatic": "^1.1.3",
    "ghostmodeify": "^0.1.1",
    "my-local-ip": "^1.0.0",
    "watchify": "^3.4.0"
  }

I get

polling-xhr.js:232 

GET http://192.168.2.109:3124/socket.io/?EIO=3&transport=polling&t=1444336564470-5 net::ERR_CONNECTION_REFUSED

@ polling-xhr.js:232Request 
@ polling-xhr.js:155XHR.request 
@ polling-xhr.js:86XHR.doPoll 
@ polling-xhr.js:116Polling.poll 
@ polling.js:118Polling.doOpen 
@ polling.js:62Transport.open 
@ transport.js:82Socket.open 
@ socket.js:220Socket 
@ socket.js:102Socket 
@ socket.js:37Manager.open.Manager.connect 
@ manager.js:205(anonymous function) 
@ manager.js:470setTimeout (async)Manager.reconnect 
@ manager.js:460(anonymous function) 
@ manager.js:474(anonymous function) 
@ manager.js:226Emitter.emit 
@ index.js:134Socket.onError 
@ socket.js:644(anonymous function) 
@ socket.js:251Emitter.emit 
@ index.js:134Transport.onError 
@ transport.js:69(anonymous function) 
@ polling-xhr.js:122Emitter.emit 
@ index.js:134Request.onError 
@ polling-xhr.js:278(anonymous function) 
@ polling-xhr.js:225setTimeout (async)Request.create.xhr.onreadystatechange 
@ polling-xhr.js:224XMLHttpRequest.send (async)Request.create 
@ polling-xhr.js:232Request 
@ polling-xhr.js:155XHR.request 
@ polling-xhr.js:86XHR.doPoll 
@ polling-xhr.js:116Polling.poll 
@ polling.js:118Polling.doOpen 
@ polling.js:62Transport.open 
@ transport.js:82Socket.open 
@ socket.js:220Socket 
@ socket.js:102Socket 
@ socket.js:37Manager.open.Manager.connect 
@ manager.js:205(anonymous function) 
@ manager.js:470setTimeout (async)Manager.reconnect 
@ manager.js:460(anonymous function) 
@ manager.js:474(anonymous function) 
@ manager.js:226Emitter.emit 
@ index.js:134Socket.onError 
@ socket.js:644(anonymous function) 
@ socket.js:251Emitter.emit 
@ index.js:134Transport.onError 
@ transport.js:69(anonymous function) 
@ polling-xhr.js:122Emitter.emit 
@ index.js:134Request.onError 
@ polling-xhr.js:278(anonymous function) 
@ polling-xhr.js:225

For now I just reverted back to 0.2.2, but what's wrong?

Macil commented 8 years ago

You need to use the h/hostname option. You'll probably want to use -h 0.0.0.0 to listen on all addresses instead of just localhost. This was a breaking change in 0.3.0. (This project is following semver. Major version updates, and minor version updates before 1.0.0 may contain breaking changes.)

Previously, the hostname and port were automatically inferred from the u/url option, but this was restrictive and didn't allow people to make the socket server listen on an address (like 0.0.0.0) that was different from what the client accessed. (https://github.com/AgentME/browserify-hmr/issues/4)

serapath commented 8 years ago

Not sure if I understand you correct. As you can see above, I'm using

 "scripts": {
    "watch": "watchify source/index.js -p [ browserify-hmr -u http://$(my-local-ip):3123 ] -p ghostmodeify -t babelify -o public/browser/bundle.js -dv"
  }

I now updated to 0.3.1 again and changed my script to

 "scripts": {
    "watch": "watchify source/index.js -p [ browserify-hmr -h $(my-local-ip) ] -p ghostmodeify -t babelify -o public/browser/bundle.js -dv"
  }

but it's not working. If i switch $(my-local-ip) for 0.0.0.0 its working, but the problem is, that it breaks my workflow developing a cordova app on my mobile phone, because it needs to connect to the server that runs on my notebook instead of searching on localhost, so it was really nice to be able to use my-local-ip instead.

Macil commented 8 years ago

You still need the -u option. The -u option controls what URL is written into the bundle. The -h option controls what address the browserify-hmr socket server listens on. Previous versions automatically guessed the hostname based on the url, but 0.3.0 split them into separate options.

serapath commented 8 years ago

oh, ok. i see. I'll try that. thx