-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
ESTree compatible AST #2123
Comments
@kdy1 What do you think about this? |
@sosukesuzuki Just a heads up, the |
I made a mistake. |
Is it expected that third party libraries will only use the swc parser? |
No, but rust <-> js is very slow and it overwhelms time used for actual work. |
I see. Out of curiosity, you are doing integration SWC and Next.js at vercel? At there, how to integrate Rust land and JS land? |
Yes. We are working on it. We are going to reimplement all transforms in rust, and call |
I found https://github.com/vercel/next.js/tree/canary/packages/next/build/swc. It looks good, thanks |
@kdy1 (The main topic of this issue) What do you think about making swc's AST consistent with ESTree, which is the de facto standard? |
What's the advantage if I make it compatible with estree? Rust does not have GC, and estree-like ast will degrade performance. |
I did not know about the performance drawbacks. The advantage is that it is much easier for existing tools such as ESLint and Prettier to use swc as a parser. |
I see. But actually, passing ast to javascript from rust is very slow. Parser itself is fast, but json serialization/deserialization is the problematic part, and I'm not sure about the way to make it fast. |
If you provide the string the user can do things like fast-json. This allows for them to choose which serializer ( |
@jdalton If it's fast enough, I think we can support babel plugins. So I think it is worth benchmarking. |
As a test of raw parse power I tried parsing |
Please see #2175 if you're interested. I've done some experiments into speeding up |
Could you share this code? |
Describe the feature
Support ESTree compatible AST.
Some options:
swc-to-estree
Babel plugin or link to the feature description
Nothing.
Additional context
Add any other context about the problem here.
I'm a maintainer of Prettier Code Formatter and I'm developing to use SWC as a parser for Prettier (Disclaimer: It is a 100% personal activity and not affiliated with any organization.) Prettier already has a code base to handle ESTree compatible ASTs well. So, if SWC supports ESTree, it will be easier. Also, ESTree is the de facto standard for JavaScript ASTs, and by supporting it, many other tools may be able to use SWC.
related: #1392
The text was updated successfully, but these errors were encountered: