Closed inkless closed 9 years ago
If the bundle isn't consumed, it won't emit an end event. I wonder how common this is? It feels messy to put bundle into flowing mode (and might create other problems with ignored chunks) but we might need to do that here.
It happens 100% of time, it happens both in my colleague's laptop and mine. I don't have this issue before, I was using 3.2.3 at that time. But then after I also upgrade it to 3.3.1, it just doesn't work. Still not sure why this happens.
Btw, I'm using grunt-watchify
3.8.0, node
v0.12.7, npm
2.11.3, grunt
v0.4.5
@inkless what version of browserify are you running? 11.0.1 has a small patch that might be related.
@substack It seems both 10.2.4 and 11.0.1 doesn't work for me... :(
I'm still not sure why this is causing issues. When I do what grunt-browserify does here: https://github.com/jmreidy/grunt-browserify/blob/master/lib/runner.js#L129-L141
var watchify = require('./')
var browserify = require('browserify')
var w = watchify(browserify(process.argv[2]))
w.on('update', function () {
w.bundle(onbundle)
})
w.bundle(onbundle)
function onbundle (err, src) {
if (err) console.error(err)
else console.log(src.length + ' bytes')
}
This works fine. Maybe grunt is doing something else strange? I'm not familiar with how to set up a grunt build, so if somebody could verify that a plain grunt-browserify build fails, that would be useful information.
@inkless Can you put together a small repo with the issue so I can try to debug it?
https://github.com/inkless/grunt-browserify-test I created a repo, I think you can reproduce it in that repo.
@inkless Thanks for the repo, it helped me figure out the problem. I submitted a fix to grunt-browserify.
The problem is that because of how npm installs semver incompatible versions, grunt-browserify wasn't using browserify@11.0.1 as you expected, but rather v10. v11 has this fix https://github.com/substack/node-browserify/commit/90a429d6c22eefa61f73840ca212e7784666660a for the problem you're having.
@inkless grunt-browserify@3.9.0 fixes this issue.
Cool thanks!
I come across an issue when the watchify upgrades to 3.3.1. So I'm using grunt-browserify in my current build process, and I have a config like this:
Somehow, when I change any file, the watch is never triggered. After I dived into it, it seems
onend
function is never triggered. But if I add another event:bundle.on('data', function() {});
, it fixed the bug. and onend is triggered, not sure why this happens, but it does help fix the problem.