oxc-project/oxc

☂️ Transformer Milestone 1

Boshen opened this issue · 7 comments

Call for help

This is a call for help; we need assistance from experts who are proficient in Babel and Rust to help us achieve the fastest and most feature-complete JavaScript transformer. The contributor need to adhere to the project rules outlined at https://oxc-project.github.io/docs/contribute/rules.html.

Background

When I prototyped and created the current transformer (https://github.com/oxc-project/oxc/tree/main/crates/oxc_transformer), I was working alone and porting Babel without planning ahead. The result was a dead end - @Dunqing and I became stuck and burned out.

Fortunately, @milesj and @rzvxa showed up and offered help. After some consideration and discussion, we (@Boshen, @Dunqing, @milesj, and @rzvxa) formed a working group to tackle the transformer together.

Restart from scratch

Although we have a significant amount of code in https://github.com/oxc-project/oxc/tree/main/crates/oxc_transformer, with 320 out of 1415 tests passing (as indicated in https://github.com/oxc-project/oxc/blob/main/tasks/transform_conformance/babel.snap.md), let's proceed as if none of this code exists. This will allow us to restart with shared knowledge within the working group.


Milestone 1

The first milestone is to complete @babel/preset-react and @babel/preset-typescript so that tools can transform .jsx and .ts(x) files to the latest ECMAScript version.

Here's the plan:

  • Completely discard the current transformer implementation.
  • Begin anew to avoid carrying any technical debt.
  • Lay out the architecture with placeholders.
  • Proceed from both ends:
    • One group will focus on porting all APIs (@Boshen and @Dunqing).
    • Another group will work on laying out all the foundational code - AST, symbols, scope mutations, etc. See #2704 (@rzvxa and @milesj).
  • Ensure that all code is reviewed by at least two people to facilitate knowledge sharing and enable concurrent progress towards the next milestones.

The result was a dead end - @Dunqing and I became stuck and burned out.

What happened? What is the present workflow and any obstacles faced?

What happened? What is the present workflow and any obstacles faced?

Since we currently have no way to access/mutate the ancestor node, this makes it very difficult for us to implement some complex cases. Some cases rely on scopes, and with the current implementation, we don't have access to the scope corresponding to the current AST. Furthermore, any mutations we currently do are not sync semantic. That is, even if we somehow did get access to the scope, its data would be incorrect.

Here we are discussing and solving the problems we are facing #2704

There wasn't a clear scope and milestone, so we ended up trying everything all at once, which was exhausting.

Will it be possible to serialize transformed code back to the TypeScript?

It would be very helpful for the new version of my TypeScript runtime reflection I'm building.
(Old version tst-reflect. New version is currently closed alpha, but you can see demo on StackBlitz.)

To support as much build/bundle tools as possible I have to do TS to TS transforms so I don't have to implement whole system for each of them. Performance is critical so I'd like to use OXC bcs you do good job guys. 👍

@Hookyns Please could you open a separate issue for this? If we are able to support such a feature, it won't be part of this milestone - the content of which is listed above.

Milestone 1 is done. Will brainstorm for milestone 2 when we have gathered the requirements.

@Hookyns I don't know if you did open another issue in the end, but just to let you know, oxc_codegen does now output TS.