Repository navigation
Node.js Amaro Features #12378
Description
Activity
From nodejs/node#66051, my understanding is that you want to use SWC to replace some of Node’s existing uses of Acorn.
I’d suggest keeping the type-stripping implementation and general-purpose lexer, parser, AST, and visitor infrastructure in SWC, while implementing the Node-specific functionality in Amaro.
More concretely, Amaro could have a Rust core that depends directly on SWC crates and exposes these APIs. My understanding of their intended uses is:
tokenize: expose tokens from the lexer for REPL syntax highlighting.findTopLevelAwaits: parse the source and walk the AST to collect top-level await locations for ESM diagnostics.isRecoverableError: inspect parse errors, including unexpected EOF, to determine whether the REPL should wait for more input.transformModuleSyntax: rewrite imports into declarations that make the imported bindings available to subsequent REPL inputs.
This would let Amaro reuse SWC’s underlying infrastructure while owning the Node- and REPL-specific behavior, rather than implementing that behavior in SWC’s binding crate first and then syncing it into Amaro. Type stripping would still use SWC’s Rust implementation without duplicating it.
Amaro could keep its existing WASM-based JavaScript API, while a standalone Rust core would also open up the possibility of native integration with Node.js in the future.
We’d be happy to help with this.
Reacted by Aviv KellerReacted by Aviv KellerI'm happy to work on this on the Node.js side, unless #12395 is intended to be the fix?
My plan was to merge it into the SWC repo first, and then do another PR to move it
- added a commit that references this issue
on Sep 21, 2026
tokenize(src):Token[], where a token is{ kind, start, end }with kind in keyword,identifier,number,bigint,string,template,regexp,comment,punctuator.findTopLevelAwaits(src):Array<{ line, column }>isRecoverableErrorneeds to supportSyntaxError::Unexpected { got: "<eof>" }.4.
transformModuleSyntaxso imports declare bindings (const fs = __nodeREPLImport0.default;) instead of only rewriting references within the same input.If you open a PR to help with this, I can confirm it's validity and workability before it lands. Thank you!
In the meantime, I'm opening a PR against Node core for partial Amaro replacemnet.