browserify / watchify

watch mode for browserify builds
Other
1.79k stars 181 forks source link

It doesn't work anymore #271

Closed azer closed 9 years ago

azer commented 9 years ago

Looks like API has been changed recently, and I can't get a simple example working. Here is the code I'm trying;

var browserify = require("browserify");
var watchify = require("watchify");
var fs = require("fs");

var b = browserify({ cache: {}, packageCache: {} });
var w = watchify(b);

w.add('index.js');

w.bundle().pipe(fs.createWriteStream('output.js'));

Browserify: 11.2.0 Watchify: 3.4.0

When I run it, it keeps running but does nothing when I change the files. Any ideas what I'm missing ?

asbjornenge commented 9 years ago

I have similar issues with watchify these days.

azer commented 9 years ago

If you're hitting the same error with me, try listening the update method and generating the bundle on that event. here is full working example:

var browserify = require("browserify");
var watchify = require("watchify");
var fs = require("fs");

var b = browserify({ cache: {}, packageCache: {} });
var w = watchify(b);

w.add('index.js');

w.on('update', function () {
  w.bundle().pipe(fs.createWriteStream('output.js'));
});
zertosh commented 9 years ago

This is how watchify has worked for a long time.