-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API enhancements #28
API enhancements #28
Conversation
|
@substack Awesome, thanks for the feedback. I'll clean it up. |
What did you have in mind here? It's easy to extract streams from |
Could we just have a new event that emits an event emitter that emits each stream? That would fit in well with the existing api. |
I see we've been duplicating work over the past day. :) What I was considering doing was exposing a pipeline instance for each stream, so that someone downstream could make changes to wrapping and packing. Does this help? |
@terinjokes That's a really good idea. I can give you push access to my fork if you want. |
This works for me. |
@terinjokes I rebased & overwrote the branch to get rid of the |
Gracias, getting on that. |
@jgoz Sorry about the delay. I've been busy with my real work stuff 😦. I'm going to try to get to this tomorrow (Saturday). |
@terinjokes No problem at all! This isn't blocking my real work stuff - just a nice to have. If you need help let me know! |
563f1e8
to
4eefd30
Compare
@terinjokes Do you think it would be worth merging this as-is and splitting the pipeline-per-stream feature into a separate request? That way at least it works with watchify, even if the API isn't ideal. |
I'm just hesitant on having four different possible settings for a single thing. Overloaded APIs are also confusing APIs. Let me think about it tonight, and I'll either do a follow up comment or a merge tomorrow. |
You mean for |
Function returning a stream is what I had locally to resolve the watchify issue, I'm not sure of that usefulness in the current state of a function returning a string is (I can't think of any new information in this case). That said, I primarily wanted to think about how the pipeline version would work, and jot it down either here or another ticket, before moving forward here. Would hate for this to shoot that in the foot. |
It's probably not useful at all - really just a consequence of accepting stream/string/function as possible values and not restricting the function output.
Sounds good. |
What about this: Every output stream emits a This would allow you to listen for the event and hook the pipeline as required. You also wouldn't have to pass anything for var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
// etc.
function wrap(id) {
return source(path.basename(id))
.pipe(buffer())
.pipe(sourcemap.init({ loadMaps: true }))
.pipe(uglify())
.pipe(sourcemap.write())
.pipe(gulp.dest('out'));
}
b.on('factor.pipeline', function (id, pipeline) {
pipeline.get('wrap').push(wrap(id));
});
b.plugin('factor-bundle');
b.bundle().pipe(wrap('common.js')); Advantages of this approach:
|
@terinjokes Have a look at jgoz#1 and jgoz#2 — both create pipelines for the output bundles but they're hooked differently (1 uses events, 2 uses a callback param). I prefer the callback myself. Any thoughts on either of these approaches? |
I prefer #1, trivial example aside. |
OK. Is it worth tacking that on to this PR and cleaning up as needed? |
@jgoz Probably worth it. Might be good to squash them into two commits though. |
Will do |
4eefd30
to
3b7c2fa
Compare
- works in watchify - re-adds pipeline hooks on 'reset' - add opts.outputs alias for opts.o + docs
6cad179
to
bec04df
Compare
- browserify instance emits ‘factor.pipeline’ event when the pipeline is created - pipeline uses labeled-stream-splicer and has ‘pack’ and ‘wrap’ stages
@terinjokes Squashed + added docs. |
@jgoz and @terinjokes, this is looking great! |
Thanks. I think it looks good too, but I want to take another look when I'm not sick. 😷 |
@jgoz, I tried both branches and they both worked great for me. I don't have strong preferences, so up to you guys! What I've noticed is that when I switched to your branches I had to start using absolute paths in my entries list because relative paths stopped working. Namely, they are completely ignored, though a |
oh @jgoz, I didn't notice that! |
@jgoz I'm going to rebase this and merge, assuming you have no other changes. |
@terinjokes No other changes from me! |
Sweet! |
This improves the plugin API use case for factor-bundle.
reset
— necessary when callingbundle()
multiple times, e.g., with the watchify APIAttachfactored
method to browserify instance — creates/returns athrough
stream through which all factored bundle streams will pass. Definitely open to suggestions on suitability, naming, etc.opts.outputs
alias foropts.o
to mirroropts.entries
opts.o
. This is necessary to recreate streams for multiplebundle()
calls. Works nicely with lazypipe.Added documentation around plugin usage with browserify API. The example uses gulp, but I'd be happy to change that.