substack/watchify — pull request #68 by glenjamin (2014-07-13 16:42:06+00:00)
Title: Failing testcase for errors generated by transforms (#64)

I've managed to produce a failing testcase for the issue described in #64

As discussed in the issue there, 0.8.1 is the last known good build - git bisect confirms that bcda5eb30be1183dd677d74585ed729ce2a486e4 is the first commit where the test begins to fail.

However, I think this is a red herring, and that the real issue is the removal of `queuedCloses` in ad8e483ef44cd4db28472d8c5b8640c82c291b67.

The scenario goes something like this:
1. `file` event for File A
2. File A is now watched
3. File A is modified, chokidar detects this
4. invalidate() is called for File A
5. The watch on File A is removed
6. The transform step fails due to the error, and no new `file` event is raised

Fixing the error has no effect now, as there's no active watch on the file.

I think there's two possible fixes here:
1. Have browserify emit the `file` event even if the transform fails (or before the transform runs?)
2. Only remove the watchers after the next successful bundle is completed

Hopefully @tmpvar and/or @substack can advise? I'm happy to put together the PR for either of those, or any other suggested fix.