Closed teehemkay closed 8 years ago
Thanks – this is fixed in 0.11.2. Use sourceEncoding: null
, like so:
function myPlugin ( inputBuffer ) {
return doSomethingWith( inputBuffer );
}
myPlugin.defaults = {
sourceEncoding: null
};
👍
Unless I'm mistaken, file transformers cannot be async, right?
If that's the case, it's quite unfortunate because it means that one has to chose between async or caching but can't have both?
For example: I want to have a gobble plugin for imagemin. Since optimizing is onerous and a 1-to-1 op, I'd rather use a file transform.
But imagemin processors are async so it's a no go 😞
I guess it should be possible for Gobble to detect when a file transformer returns an instance of Promise
and wait for it?
Ideally yes. And also maybe use the number of arguments trick (like for the directory transformer) so that one can use a callback instead of returning a promise.
But for the moment, it seems that gobble just assumes that the returned value is the transformed contents (see https://github.com/gobblejs/gobble/blob/f508f0bcef770fc3e66ff16bfbb89f00b2015e80/src/builtins/map.js#L75)
I've opened a feature request (#112) for this btw. So maybe it's better to further discuss this there 😄
Gobble provides the contents of an individual file to a file transformer plugin as text input. This prevents a file transformer from handling binary files which is quite a bummer.
For example, since image optimisation can be quite onerous in terms of performance, a file transformer for image optimisation could be more performant than a directory transformer thanks to caching.