Open Zn4rK opened 1 year ago
Aren't there performance overhead in FFIs? As far as I know oxc uses napi-rs to communicate between rust and js.
There's a performance overhead, but parsing a big document with OXC is still faster than what I do today. I have a transformer implemented in SWC, but I would like to replace that with JS instead. My initial experiments tell me that I can shave of a few ms by doing it this way.
Another fast ESTree parser is oxc.
https://github.com/web-infra-dev/oxc#-ast-and-parser
However the generated ESTree AST slightly differs:
But it would be pretty awesome if it was supported!
The additional distinct types is quite a big change I would think:
OXC ESTree AST
```js const helloWorld = "Hello World"; ``` ```json { "type": "Program", "start": 0, "end": 34, "sourceType": { "language": { "typeScript": { "isDefinitionFile": false } }, "moduleKind": "module", "variant": "standard", "alwaysStrict": false }, "directives": [], "hashbang": null, "body": [{ "type": "VariableDeclaration", "start": 0, "end": 33, "kind": "const", "declarations": [{ "type": "VariableDeclarator", "start": 6, "end": 32, "id": { "type": "BindingPattern", "kind": { "type": "BindingIdentifier", "start": 6, "end": 16, "name": "helloWorld" }, "typeAnnotation": null, "optional": false }, "init": { "type": "StringLiteral", "start": 19, "end": 32, "value": "Hello World" }, "definite": false }], "modifiers": null }] } ```Regular ESTree AST
```json { "type": "Program", "start": 0, "end": 33, "body": [ { "type": "VariableDeclaration", "start": 0, "end": 33, "declarations": [ { "type": "VariableDeclarator", "start": 6, "end": 32, "id": { "type": "Identifier", "start": 6, "end": 16, "name": "helloWorld" }, "init": { "type": "Literal", "start": 19, "end": 32, "value": "Hello World", "raw": "\"Hello World\"" } } ], "kind": "const" } ], "sourceType": "module" } ```I haven't found another library for traversing a OXC compatible ESTree in Javascript yet.
The node types are available in https://github.com/web-infra-dev/oxc/tree/main/crates/oxc_ast/src