Closed jgoz closed 10 years ago
i'm still trying to diagnose this, but after this executes correctly the first time with browserify, it consistently crashes a second time using substack/watchify, with the following relatively unhelpful console message:
events.js:72 throw er; // Unhandled 'error' event ^ Error: ENOENT, open 'eeO1y8'
i'm guessing that means it's trying to open a key somewhere instead of a file path, but i haven't yet been able to identify where.
Hmm, I didn't test it with watchify - thanks for doing that. I'll look into it too.
Merged in 1.0.0. Thanks for the patch! watchify hasn't been made to work with factor-bundle yet so this patch doesn't affect that.
@substack
watchify hasn't been made to work with factor-bundle yet so this patch doesn't affect that
On that subject, I spent a bit of time debugging tonight and figured out how to make it work with watchify. Whether it fully benefits from the caching that watchify provides is another question.
Anyway, there were 2 issues with the current implementation:
bundle
that updates rmap
was changing the ids of the original rows that were getting passed through, which was messing with watchify's cache. Cloning the rows in the through stream fixes that.bundle
, so further calls will not trigger the stream
and data
events, producing an empty common bundle. This is solved by re-initializing the stream when it ends. It's kind of a hack and I'm not super happy with it, but it works.My solution is pretty messy at the moment, so it might take a larger scale cleanup before submitting a patch.
This fixes #13.
Instead of ints, this uses the
browserify._hash
method on module ids in both entry and common bundles. Common dependencies are added tobrowserify.exports
to ensure their hashes are exposed (simulates using-x
and-r
to generate factored output).The cost of improved accuracy is a few extra bytes per dependency.
Note that this requires browserify ^3.30.5, due to the use of
._hash
. I took the liberty to update some dependencies in this PR, but I can revert that if you like.