file transforms #15
Comments
in the example the transform only pulls from a |
woops, sorry, incomplete example. updated. working on it right now. I think I can get it working with an internal queue. |
The api for streams we'd need is: function styl(opts){
return function(){
return transformStream();
}
} |
I think in the example you'll also get each file content written to stdout 3 times, as there are 3 pipes from t to stdout |
then you'd need to wrap every gulp stream though |
haha i think that's my current bug :-P |
var fs = require('fs');
var map = require('map-stream');
function prepend(str, fn) {
return fn(null, 'hi ' + str);
};
function t(){
return map(prepend);
}
var a = fs.createReadStream('./a.txt', 'utf8');
var b = fs.createReadStream('./b.txt', 'utf8');
var c = fs.createReadStream('./c.txt', 'utf8');
a.pipe(t()).pipe(process.stdout);
b.pipe(t()).pipe(process.stdout);
c.pipe(t()).pipe(process.stdout); |
i guess we could do something like... duo
.use(wrap(styl)(opts)) pretty ugly though |
this is already implemented in
no clue on how gulp works, didn't have a chance to look into it, but if function plugin(opts){
return function(duo, done){
var stream = stuff(duo);
stream.on('error', done);
stream.on('close', done);
};
} no clue why streams will be useful, do people really want to transform coffee to js using a stream ? |
<3
the problem is that we're using the same instance of the transform over again. that's totally f-ing things up haha.
it allows you to do stuff like: entry.js var a = require('./a.coffee'); or import a from 'yields:shortcuts' which would get transformed into: var a = require('yields:shortcuts').a; which would then get picked up by That's the idea anyway, haha. |
the reason i want gulp is so we don't have to write all this crap ourselves. |
aha, fair enough +1 for streams then, don't want to write those things too ;) |
i have an idea that might make things easier: go with |
hmm, could you show me in some code? i'm not sure i follow. |
ahh interesting, the files are read in levels, so I'm not sure that will work: entry.js: require('yields:shortcuts')
require('./a.coffee')
require('./b.coffee') First recursion: parse Which would result in: parsing ./a.coffee: gulp('a.coffee').pipe(t) parsing ./b.coffee: gulp('./a.coffee').pipe(t) // same instance of t |
i think i have a solution, so don't think too much about it ;-) |
okay this isn't going to happen haha. the main module people use for gulp-plugins |
sounds good, i don't mind releasing without gulp support mainly because wrapping them will be easy, almost like
i was thinking we could just |
haha yah streams right now is a total clusterfuck, with like half the modules still implementing streams1.
yep that's what i was thinking. i'll come up with an example of using gulp in duo, you want to take the |
yup :) |
add |
i've been thinking a lot about file transforms lately and I think I've come up with a decent solution. Here's what the API would look like:
Where
styl
andjade
are one of the following:function(...) { return compiled }
function(..., fn) { return fn(null, compiled) }
The reason I'm pushing for gulp streams is that it will allow us to tap into a huge repository of plugins for things like: transpiling ES6 => ES5 (adding
import
, etc), coffeescript support, and many other things I haven't thought of.However, the problem I'm running into is the following. Maybe this is obvious to someone that's worked a lot with streams, but basically if you do the following, you will not get the intended results:
Basically, the transform stream pulls from all 3 sources at the same time. This is a problem because gulp streams are already initialized by the time they're passed through (ie.
styl()
).What needs to happen is the files need to be queued and wait until the transform pipeline is free. I'm not sure if this is going to be a bottleneck yet, or if there is a better way, but that's what I'm facing right now.
I guess to get duo out there maybe we can just support the first 2 options (sync and async fn), but I think the gulp streams will be a huge plus for people.
How we'll walk the files is the following:
main.css:
To resolve
three
we will base it off the root entry (extname("main.css") => ".css" => "./three.css"
). We will do the same for JS and eventually HTML./cc @yields @juliangruber @ianstormtaylor
The text was updated successfully, but these errors were encountered: