Bublé: a fast, batteries-included ES2015 transpiler
buble.surge.sh
buble.surge.sh
That and your positive experience just sealed the deal for me. Thanks for sharing.
Is that really good idea when looking at the possibility of introducing bugs in the transpiler?
It's definitely trickier but I think it's possible to do this in a clean way if the changes are just "replace this AST node with this other AST node". You know the text boundaries, and the output is context free so...
That's what a test suite is for :)
I really wish people called it BabelScript. It's annoying to constantly have to fight the (incorrect) assumption that "it works in Babel" === it's ES.
So, the correct spec-compliant thing to do would be for the ES2015 preset not to touch import/export and let the bundler handle that (hopefully correct). Compiling to CommonJS, which doesn't care about `.js` or not, is the wrong choice.
Or maybe it's now part of ES2016? I get quite lost in those sliding features...
It certainly takes its time :) Well, Bublé sound cool for projects where feature stability over time is critical (like huge codebases), but I will still prefer to go with babel to select which stage I want.
EDIT : just to be clear, I won't advice any sized team to go with staged features. It works for me because I do a lot a small sized project working alone on them and I'm ok refactoring their codebase if a feature implementation change.
It really does cleanup a lot of code, but getting people to understand that an Async function returns a promise isn't always the easiest thing to convey until after it's been used. I resisted Promises for a while, once it became a part of ES6, and with async/await in Babel, I started using it... the cleaner code is worth the minor bit of overhead.
https://github.com/alexmingoia/jsx-transform/
I think it would not be too much work to wrap it in a script to let you pipe into/out of other build steps.
You want to write ES6 code today, but your clients (= browsers) don't support it yet. So you use the transpiler: write ES6, compile to ES5, serve that.
It's the opposite of what Python did with the 2to3 tool, where you wrote Python 2, and converted it to Python 3 before running.
Why do you want to write ES6? Well, hopefully, every change ES6 introduces to ES5 is an improvement. I'd hope. So every different thing between them, you'd want to use, sort of by definition. That's the idea, at least :)
Not every piece has to be useful to everyone.
I don't quite follow why plugins are discouraged in your FAQ section. I was looking at this Gulp plugin (it's very new, but looks straightforward/is idiomatic gulp): https://github.com/TrySound/gulp-buble -- I'm not following why that would be an anti-pattern.
I'm still unsure what they offer over a simple object with property key values.
They offer a particular abstraction, that gives a certain automatic conceptual clarity for free. Personally, I'm a massive fan of prototype-based object systems, but having the class syntax sugar on top of it has made certain patterns clearer to express even if it's semantically equivalent.
My main issue with ES2015 classes, is that I've seen some projects use it for everything including things that it's really not required for; really putting the _Java_ back in Javascript, so to speak. But that can be said for a lot of language features, really.
That said, when you need encapsulation and instance isolation classes provide a nice sugar around prototyping. They tend to work very well for components that have visual interactions/events that are tethered to instance/scope state. I tend to prefer the React+Redux model myself, but there are times when you need more than render-only components, and in those cases the class syntax means cleaner source code imho. These cases are also very limited imho, and about the only place I use class syntax.
However, I'd say one of the primary reasons for existence of classes would be familiarity. A lot of developers would have experience with classes in other languages so it is useful to have similar entity in JS.
Question - how to have buble accept input from stdin and output to stdout? This is useful for quick ES6 tests and chaining piped output.
buble with no args prints help. Would be more useful if it just started parsing code from stdin as babel 5.x did.
cat somefile.js | buble
– can you explain in more detail what you mean? (Or better yet raise an issue :)The idea is for Bublé to eventually become irrelevant (planned obsolescence) – but as new language features do arrive it will be fairly straightforward to add them. I'm just not sure if there'll be that many more language features after ES2017, at least of the transpilable sort – I'd be surprised if we ever have another big bang like ES2015 was.
Having said that, I'm very interested in seeing where https://github.com/marten-de-vries/kneden goes.
All of that said, I think it's definitely worth it, and the extra size is less of a difference for larger projects. For server-side code, the size is less of a difference since it isn't downloaded, and the performance impact has been negligible in terms of noticeable, real-world performance.
Of coure by the end of 2017 I expect most browsers to have implemented async/await natively... so by 2019 won't be an issue... that said, it's still 2016, so I'll keep using Babel.
Why would I ever use this instead of TypeScript? A totally reasonable answer to this question is that I don't want my JavaScript sources to require transpilation before they will run in a modern browser.
Exactly this. Bublé is designed to become increasingly redundant as node and browsers progress, until one day you can just remove it from your stack altogether. Planned obsolescence is an underrated feature in software
If anyone can help me out with a less gross version of the same metaphor I'd be grateful!
(It has since grown a lot and added a lot of modern features that are not guaranteed to be in JavaScript in the future, but I think the point still stands.)
Even then, I don't blame TS for most of it... but the typedef tooling really should be in the box, and have a standard construct for usage. In the end, for my example above, I used babel with some flow plugins, and it worked well enough.
I believe most people use Babel to compile async/await to generators.