These are chat archives for milankinen/livereactload

18th
Apr 2015
Frankie Bagnardi
@brigand
Apr 18 2015 10:56
I'm getting a really weird error here: require("livereactload/lib/browser/add-reactload-deps")(4474, require("react"), require("react/lib/ReactMount"));; saying Uncaught TypeError: require(...) is not a function
this happens on page load
also for some reason it's trying to read from static/.bundle.js (note the dot), so I had to write to there... maybe related; I'm using the shell script from the readme
Frankie Bagnardi
@brigand
Apr 18 2015 11:12
well I got past the first one by upgrading watchify, but I still have no idea about this static/.bundle.js thing
Fannar Snær Harðarson
@fannarsh
Apr 18 2015 11:20
Hi,
When browserify or watchify builds the bundle, it starts of with creating a temporary file which is the one your are seeing as static/.bundle.js and if the build is without errors the static/.bundle.js is renamed to static/bundle.js
Frankie Bagnardi
@brigand
Apr 18 2015 11:26
thanks, okay so the builds are working now, but every build after the first is causing the require(...) is not a function error
if I kill watchify, and run it again, everything is correct; but the second build in a single watchify session is producing invalid code (even if the source is the same)
my slightly modified build script (added SimpleHTTPServer and made it -t, react is the only npm dependency used in my code)
bin_path=

python -m SimpleHTTPServer 3131 >/dev/null 2>&1 &

{ { "${bin_path}"watchify dev.js -v -t babelify -t livereactload -o static/bundle.js 1>&2; } 2>&1 \
  | while read result; do
    echo "$result"
    [[ "$result" =~ ^[0-9]+[[:space:]]bytes[[:space:]]written  ]] && "${bin_path}"livereactload notify
  done
} &

"${bin_path}"livereactload listen
wait
Frankie Bagnardi
@brigand
Apr 18 2015 11:31
watchify, livereactreload, react, babelify are all the latest version
Frankie Bagnardi
@brigand
Apr 18 2015 11:41
hmm... require("livereactload/lib/browser/add-reactload-deps") returns an empty object, which indicates something insane or a circular dependency
Fannar Snær Harðarson
@fannarsh
Apr 18 2015 12:06
I haven’t actually started to use livereactload, I plan on using it for my next project though.
But if I would guess, then it is this part that is failing.
https://github.com/milankinen/livereactload/blob/master/lib/browserify/transform.js#L40
Could it be that you do not have a package.json in your project?
Frankie Bagnardi
@brigand
Apr 18 2015 12:07
oh darn, not in this directory (it's a sub application)
thanks
Fannar Snær Harðarson
@fannarsh
Apr 18 2015 12:07
hmm.. that shouldn’t be it since your line above says livereactload
I’m just wildly guessing here but it could be related
Frankie Bagnardi
@brigand
Apr 18 2015 12:08
node_modules and package.json are several directories above this, so I'll try making this its own package
Frankie Bagnardi
@brigand
Apr 18 2015 12:13
that fixed it, thank you so much! :-)
wait... nope, it looked like it was fixed for a minute :/
time to read the source
Frankie Bagnardi
@brigand
Apr 18 2015 13:14
I'm guessing it's something wrong with my setup (it's an edge case), but I ended up getting webpack hot working here; I'll try this again under more sane circumstances :-)