Skip to content

feat(swc): export bindings for parsing JS to AST#435

Open
avivkeller wants to merge 1 commit into
nodejs:mainfrom
forked-by-avivkeller:ast
Open

feat(swc): export bindings for parsing JS to AST#435
avivkeller wants to merge 1 commit into
nodejs:mainfrom
forked-by-avivkeller:ast

Conversation

@avivkeller

@avivkeller avivkeller commented Jun 28, 2026

Copy link
Copy Markdown
Member

As I mentioned on Slack, if I export the SWC bindings for AST parsing, we can use them in Node core, removing our reliance on two separate AST parsers (SWC and Acorn)

Signed-off-by: avivkeller <me@aviv.sh>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I should upstream this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it needs to be upstreamed

@acutmore

Copy link
Copy Markdown

Node core, removing our reliance on two separate AST parsers (SWC and Acorn)

I'm curious why there is a desire to drop Acorn as a dependency? Is there an issue where that is being discussed?

Some benefits of Acorn:

  • will work with node --jitless
  • less than 300kb
  • (likely) faster to create a JS AST
    • The current Amaro APIs are string->string rather than lots of little objects

@avivkeller

Copy link
Copy Markdown
Member Author

To clarify, we have no issue with Acorn, I mostly want to reduce our code duplication, for instance, having two AST parsers.

@acutmore

Copy link
Copy Markdown

Thanks for clarifying. Reducing duplication makes sense, I'm just wondering if the end user impact is worth it.

For the performance cost, it might work out cheaper to have more specific APIs than exposing the whole AST. Such as only returning the exports of the file or if it has top level await.

For the --jitless issue, maybe there is a way to have wasm run only by an interpreter (easier said than done I'm sure).

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.

3 participants