dk00 / livescript-next

Enable latest ES features for LiveScript
https://lsn.netlify.com/
The Unlicense
39 stars 3 forks source link

LiveScript integration #9

Open rhendric opened 7 years ago

rhendric commented 7 years ago

Love the work you're doing here. Now that I have commit bits on LiveScript proper, and since gkz has said he'd bless adding an ES6 output mode, I want to help you get a clean path to landing this in LS if you want.

How can I help?

(Note, I've been treating the AST API as internal; I've refactored some bits here and there since the 1.5 release and I intend to do more, but I don't want to unduly jeopardize the good work you're doing here. If you have, for example, interfaces you particularly want to preserve, or new ones to create, I'd be happy to work with you on this.)

dk00 commented 7 years ago

Thank you.

The code should be easy to integrate, but I'm using different approach(nyc + babel-istanbul) for testing and code coverage, and can't be ran together with current LS test. We could run the tests separately and merge the coverage reports, or use nyc for both. I will make a PR for these.

After integrating the convert function, we can add an option for new output modes.

Refactoring AST API is fine, as long as it maintains or improves consistency, and consistency really helps. LS AST is used like a plain object here, so there's no need to change if the shape of AST is not changed. .children is used to traversing the AST, this is the only the interface I want to preserve.

rhendric commented 7 years ago

The shape of the AST has changed a little bit. For example, in this PR, I changed how object expressions were parsed. {a, ...b, c ? 0} used to parse as

Obj [Key \a; Splat Var \b; Binary \?, Key(\c), Literal(0)]

but now parses as

Obj [Prop null, Var \a; Prop Splat!, Var \b; Prop null, Binary \?, Key(\c), Literal(0)]

The upshot is that now Obj nodes can be expected always to hold Props (and the occasional raw JS comment) instead of a zoo of other things, which I think is a win for consistency but presumably would require your converter to keep up.

How's your feature coverage so far? Is hosting lsc on Babel within sight, or are there still large pieces missing?

dk00 commented 7 years ago

I have updated the converter to keep up with latest LS.

This project is self-hosting from the beginning, so at least hosting the converter itself is possible. Many of LS features are covered now, missing features are:

class is the most tough one.