jstransformers / jstransformer

Normalize the API of any JSTransformer.
http://npm.im/jstransformer
MIT License
153 stars 12 forks source link

Switch to Unified API #141

Open RobLoach opened 8 years ago

RobLoach commented 8 years ago

https://www.npmjs.com/package/unified

Would end up being like the following:

var jade = jstransformer().use(jade);
var output = jade.process(input);

Or https://github.com/jonschlinkert/base-methods may be another option.

Using this API would allow easy piping between the Transformers.

ForbesLindesay commented 8 years ago

Personally, I think piping should be a higher level concern, not something we handle at this level. Our transform's uniform interface is a string, rather than an AST, so we don't need to think about splitting out parse/compile stages. I think we should avoid the added complexity.

tunnckoCore commented 8 years ago

I think we should avoid the added complexity.

:+1:

@RobLoach Also, i thought for it when you posted the issue, but. Can you show some example (with multiple transformers) and what you would expect?

It would be too complex to be implemented, even without unified, base, use or any other thing like that.

I can think only for one example that may be useful: str -> Rework (or some pre-processor) -> PostCSS -> output

Or okey, another think... str -> [mustache ->] handlebars -> htmlmin -> output, but what if one jstransformer supports only async api? And more questions pops up, imho.