Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start work on the babel pipeline #862

Closed
wants to merge 1 commit into from
Closed

Conversation

AriaMinaei
Copy link

As discussed in #821, these are the minimal changes required to start working on the babel pipeline.

To test it out:

LiveScript = require \livescript

code = """
function suma a, b
  a + c
"""

console.log LiveScript.babelPipeline.compile code

For now, it can only compile this code:

function add a, b
  a + c

Here is how the pipeline will probably work:

  1. simplifyLsNode makes LS AST easier to read with console.log(). This doesn't affect the rest of the pipeline, and only makes debugging easier.
  2. The simplified AST is fed to lsASTToBabelAST. This will turn a simplified LS AST to a babel-compatible AST, similar to what babylon.parse returns.
  3. At this point, we do have an AST that we can generate JS code from, but LiveScript's semantics, such as last-expression-gets-returned, aren't preserved. We'll need to write a bunch of babel transforms to preserve those semantics.
  4. Once we have a valid babel-compatible AST with LiveScript's semantics, we can either generate JS code, like this, or feed the babel-compatible AST to babel-eslint, by changing this line from var parse = require("babylon").parse to var parse = require('livescript').babelPipeline.parse.

@auvipy
Copy link

auvipy commented Feb 22, 2016

cool

@darky
Copy link
Contributor

darky commented Mar 8, 2016

I think need to create drop-in replacement of ls-ast in favor to babylon-ast.
That is:

ls-tokens -> babylon-ast

instead

ls-tokens -> ls-ast -> babylon-ast

Must be more faster, flexible and robust.

@vendethiel
Copy link
Contributor

no, that'd leave the burden of transformating Ls constructs to the lexer/grammar, which is a bad idea. It's probably better to have a "toBabelNode" or something on the AST directly (exactly in the same way we recursively compile nodes to js fragments)

@JoyKrishnaMondal
Copy link

babel sucks - enuf said.

@vendethiel
Copy link
Contributor

@JoyKrishnaMondal That's both inconstructive and uninteresting. Let's avoid this kind of comments.

@JoyKrishnaMondal
Copy link

Fine,

Babel 6 requires a .babelrc file ( dafaq ? you guys are just a compiler - stop trying to make a platform happen - its not going to happen )

Babel documentation is a lot less helpful then the community is ready to admit - half the stuff is not updated to reflect recent changes.

ES6 exists on a much lower level in terms of programming language compared to livescript - why it gets more attention is beyond my comprehension.

Babel is more concerned about marketing then improving docs or the code itself.

The babel community is much more dismissive then any other OSS community I have seen out there - I personally just follow their issues rather than use babel myself.

these are just some of the problems I have with babel. I just do not want babel to dominate and replace typescript,live-script,coffeescript . . . just because they have a better marketing team.

@AriaMinaei
Copy link
Author

@JoyKrishnaMondal This better be discussed in #821. Please read my first post where I explain why I think we should do this.

@AriaMinaei
Copy link
Author

I like @vendethiel's idea that we just add a ::toBabelNode() method to each Node class. But I don't know if it'll be cleaner and more maintainable than lsASTToBabelAST. Let me do a little experiment and let you know how it goes.

@vendethiel
Copy link
Contributor

lsASTToBabelAST is basically a huge switch/case, whereas our current approach in the codebase is to use OO. Let's stay consistent.

@tomByrer
Copy link

Any progress?

@dk00 dk00 mentioned this pull request Jan 23, 2017
@auvipy
Copy link

auvipy commented Feb 15, 2017

really looking forward to see this moving ahead

@determin1st
Copy link

@AriaMinaei

it's a lot of work to sync those, but benefits are not clear. intellisense?

@AriaMinaei
Copy link
Author

Closing in favor of livescript-next

@AriaMinaei AriaMinaei closed this May 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants