Open michaelBenin opened 9 years ago
Good thing about this server is that we're not bounded to browserify or watchify, to be honest :) We just watching a file and broadcast it's changes (diff), in principle it can by any filetype.
By the way, post
=== time
? I can't find anything more suitable for this purpose (see https://www.npmjs.com/package/watchify#events)
This would actually not need any kind of file watching, it would only hook into watchify:
bundler.bundle(function (err, buf) {
if (err) {
rejectBundle(err);
return false;
}
// Resolve bundle would then hook into
// browserify patch server
resolveBundle(buf);
});
As you could see in the code, I watch files from the bundle, but not the bundle itself, because it could be quite slow. Sometimes, even incremental rebuild may take ~3s, when raw file update time always takes const time. Simply put O(n) takes more time than O(1).
This is the equivalent of watching when the build finishes it just doesn't write the file.
The point is that I don't want to wait till whole bundle gonna be rebuilt. If you I misunderstood and you propose the same solution without adding additional watcher - that's awesome, I would really like to merge it :+1:
https://github.com/Kureev/browserify-patch-server/blob/master/makeWatcher.js
Maybe we could hook into watchify's post bundle?