chrisdickinson / beefy

local development server that aims to make using browserify fast and fun
http://didact.us/beefy/
MIT License
800 stars 49 forks source link

beefy crashes if used as a module with watchify #51

Open mikolalysenko opened 10 years ago

mikolalysenko commented 10 years ago

In beefy 2.0.1, running with watchify 0.10.2 doesn't work. For example, in glslify-workshopper I get the following message if I run with watchify installed:

/Users/mikolalysenko/GitHub/glslify-workshopper/node_modules/beefy/lib/bundlers/watchify.js:45
      return watchifies[entryPath]()
                                  ^
TypeError: Property '/Users/mikolalysenko/GitHub/glslify-workshopper/menu/index.js' of object #<Object> is not a function
    at Object.handlePath [as command] (/Users/mikolalysenko/GitHub/glslify-workshopper/node_modules/beefy/lib/bundlers/watchify.js:45:35)
    at handle (/Users/mikolalysenko/GitHub/glslify-workshopper/node_modules/beefy/lib/handlers/bundle.js:48:27)
    at handle (/Users/mikolalysenko/GitHub/glslify-workshopper/node_modules/beefy/lib/handlers/log.js:42:5)
    at beefyMainHandler (/Users/mikolalysenko/GitHub/glslify-workshopper/node_modules/beefy/lib/create-handler.js:42:12)
    at handler (/Users/mikolalysenko/GitHub/glslify-workshopper/node_modules/beefy/index.js:77:5)
    at Server.<anonymous> (/Users/mikolalysenko/GitHub/glslify-workshopper/index.js:88:14)
    at Server.EventEmitter.emit (events.js:98:17)
    at HTTPParser.parser.onIncoming (http.js:2108:12)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)
    at Socket.socket.ondata (http.js:1
npm ERR! glslify-workshopper@0.0.0 start: `mkdir answers; cd answers && NODE_ENV=development node ..`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the glslify-workshopper@0.0.0 start script.
npm ERR! This is most likely a problem with the glslify-workshopper package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     mkdir answers; cd answers && NODE_ENV=development node ..
npm ERR! You can get their info via:
npm ERR!     npm owner ls glslify-workshopper
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/usr/local/bin/npm" "start"
npm ERR! cwd /Users/mikolalysenko/GitHub/glslify-workshopper
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/mikolalysenko/GitHub/glslify-workshopper/npm-debug.log
npm ERR! not ok code 0

I think it might be better long term to pin beefy to a specific version of watchify, rather than letting this float. Even though these projects are relatively well maintained it is possible for watchify/browserify to introduce breaking changes and locking to a specific version via semantic versioning seems like a better solution going forward.

chrisdickinson commented 10 years ago

Found out where the problem is -- there's actually two things going on:

  1. Beefy prefers watchify if it is locally available. That means that if someone has watchify in a node_modules dir anywhere up from their current working directory, it'll try to use it. If the workshopper is globally installed, and watchify is globally installed, this means it will try to use the globally installed watchify (since it's in a node_modules directory up from the file's location).
  2. Beefy is making a huge mistake with regards to parsing options. Fixing that part now. Once this is fixed it should work with watchify.
wmayner commented 10 years ago

+1