Live data from Hacker News

Turn your ES5 code into readable ES6

github.com

1–10 of 31 posts

Re: Turn your ES5 code into readable ES6

#6

Hmm. How smart is it? Can it detect when some usage of prototypes is not class-like and not convert it to an ES6 class?

In case you said, it can discern non-class-like function as nothing is assigned to its prototype.

Bu on the whole I cannot really tell you how smart it is because it is in alpha stage. We need more users to test it.

Re: Turn your ES5 code into readable ES6

#7

There's also this one https://github.com/mping/5to6

Yes, And it's 3 days younger than xto6. It does not support function/prototype => classes. And also it is trying to encourage people to convert their ES5 codes into ES6 but it's implemented in ES5 itself !

Re: Turn your ES5 code into readable ES6

#9
post #2

Interesting idea, but the backwards compatibility of ES6 means that you can refactor a project piece by piece as you work on it - IMO that's a better approach.

Sure, but even just as a learning exercise it's fun to pass ES5 code through it, particularly for people not familiar with the new features in ES6.

It could definitely do with a list of supported/unsupported functionality.

Re: Turn your ES5 code into readable ES6

#10
I have started a similar project, but stopped working on it, and seeing this I decided to put it on GitHub, even though it's not very well tested and not feature complete.

The most complex feature in my code is the ability to turn var into let/const optimally using an esgraph-based dataflow analysis, and it also has the ability to introduce arrow functions, shorthand/method properties and classes.

It is implemented as a fork of Babel with slightly changed packaging and a bunch of ES5-to-ES6 passes.

I'm not sure if I'm going to do any further work on this, so feel free to incorporate the code into your project if you find it useful or start maintaining a fork.

It has been tested a bit but as much as it should, so it may not just work out of the box.

You can find it at https://github.com/luca-barbieri/5to6

Post reply on HN