Kureev / browserify-patch-server

Patch server for browserify
15 stars 0 forks source link

Is it possible to have a hook in watchify post bundle instead of watching the built file? #1

Open michaelBenin opened 9 years ago

michaelBenin commented 9 years ago

https://github.com/Kureev/browserify-patch-server/blob/master/makeWatcher.js

Maybe we could hook into watchify's post bundle?

Kureev commented 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)

michaelBenin commented 8 years ago

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);
    });
Kureev commented 8 years ago

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).

michaelBenin commented 8 years ago

This is the equivalent of watching when the build finishes it just doesn't write the file.

Kureev commented 8 years ago

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: