browserify / watchify

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

Pipeline not being exposed? #284

Closed jasonmcaffee closed 8 years ago

jasonmcaffee commented 9 years ago

I tried for a couple of hours to get watchify working with my existing build process, but was unsuccessful.

I could get the 'update' event to fire, and the build to kick off, however, the pipeline label did not continue to function as it does in my normal build.

var globalBundler = createBundler();
var globalWatchifyBundler = watchify(globalBundler, watchify.args);
globalWatchifyBundler.on('time', function(time){
   console.log("TIME: " + time);
});

gulp.task('watchify', function(){
   bundle(globalWatchifyBundler);

    globalWatchifyBundler.on('update', function(){
       bundle(globalWatchifyBundler); // i also tried passing the globalBundler, but that didn't work
    });
});

The createBundler function attaches a label function to the pipeline via:

bundler.pipeline.get('label').splice(0, 1, through.obj(function (module, enc, next) { ... );

I use the labeler primarily so that dependencies can be referenced through an absolute path, rather than a relative path. e.g. require('core/view') instead of require('../../core/view');

The labeling doesn't appear to take place when using watchify, but works fine when I don't use watchify.

zertosh commented 9 years ago

It's working as expected: https://gist.github.com/zertosh/a53adf08342e772ceccc. Can you be more precise as to what you mean by "The labeling doesn't appear to take place when using watchify"?

Could it be that you're not reapplying your labeler after each reset?

jasonmcaffee commented 9 years ago

@zertosh thanks for putting that together. I gave it a try, and it doesn't work with my build process.

The label definitely worked with your approach though, so I think this can be closed.

Now the problem is: the watch picked up on the right file, and re-bundled, but for some odd reason it's not generating a new bundle.

Thanks again

zertosh commented 8 years ago

@jasonmcaffee Hmm, if you can provide me with a small repro case, I can take a look

zertosh commented 8 years ago

@jasonmcaffee any updates on this?

jasonmcaffee commented 8 years ago

No sorry. I'd love to use watchify but I'd have to rewrite my build process, and I don't have time to do that right now.
As far as I'm concerned, you solved the original issue, so this can be closed. Thanks for the help!