nft icon indicating copy to clipboard operation
nft copied to clipboard

Improve performance of AST parse

Open styfle opened this issue 1 year ago • 0 comments

We currently use acorn for parsing JS into the AST, however there are faster alternatives now.

One of the fastest, @swc/core, is used by Next.js so its perhaps possible to parse once and share the AST so that nft wouldn't need to parse again. However, this could lead to a major rewrite since the AST is not compatible.

  • Related Issue: https://github.com/swc-project/swc/issues/2123
  • Docs: https://swc.rs/docs/usage/core

Another alternative, hermes-parser, is used by React Native and should have the same AST format (ESTree) which might mean its a drop-in replacement for acorn.

  • Package: https://www.npmjs.com/package/hermes-parser
  • Repo: https://github.com/facebook/hermes

styfle avatar May 15 '24 15:05 styfle