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

☂️ Transformer Milestone 1 #2859

Closed
Boshen opened this issue Mar 29, 2024 · 7 comments
Closed

☂️ Transformer Milestone 1 #2859

Boshen opened this issue Mar 29, 2024 · 7 comments
Assignees
Labels
A-transformer Area - Transformer / Transpiler

Comments

@Boshen
Copy link
Member

Boshen commented Mar 29, 2024

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:
  • Ensure that all code is reviewed by at least two people to facilitate knowledge sharing and enable concurrent progress towards the next milestones.
@Boshen Boshen pinned this issue Mar 29, 2024
@Boshen Boshen self-assigned this Mar 29, 2024
@Boshen Boshen added the A-transformer Area - Transformer / Transpiler label Mar 29, 2024
@Boshen Boshen changed the title ☂️ Transpiler / Transformer Milestone 1 ☂️ Transformer Milestone 1 Mar 29, 2024
@Boshen Boshen added this to the Transformer Milestone 1 milestone Mar 29, 2024
@magic-akari
Copy link
Contributor

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?

@Dunqing
Copy link
Member

Dunqing commented Mar 30, 2024

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

@Boshen
Copy link
Member Author

Boshen commented Mar 30, 2024

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

@Hookyns
Copy link

Hookyns commented May 16, 2024

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. 👍

@overlookmotel
Copy link
Contributor

@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.

@Boshen
Copy link
Member Author

Boshen commented Jun 21, 2024

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

@Boshen Boshen closed this as completed Jun 21, 2024
@Boshen Boshen unpinned this issue Jun 21, 2024
@overlookmotel
Copy link
Contributor

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-transformer Area - Transformer / Transpiler
Projects
None yet
Development

No branches or pull requests

5 participants