Skip to content

xeho91/js-ast

Repository files navigation

js-ast

This is a monorepo with packages to boost the DX of working with AST (using JavaScript programming language) related to:


Core goals

  1. DX friendly.
  2. Cross-runtime friendlyβ€”πŸ‘ˆ this also means ESM only.
  3. e18e friendly.
  4. Extensive tests and benchmarks.

Packages

In order to work with AST, the following processes are recognized:

  1. Parsing stringified code syntax into AST object.
  2. Traversing the AST object.
  3. Analyzing the AST object(s).
  4. Building programmatically the AST node(s), or an entire object.
  5. Printing the AST object back into stringified code syntax.

Important

The following lists of packages contains what you can combine together - based on shared AST node interface format - aligned with ESTree specification.

Note

Not all of these packages are part of this monorepo.

Parse

Getting the AST object from stringified code syntax.

Name Languages In this repository?
@swc/core icon-jsicon-ts ❌
svelte/compiler icon-svelte ❌

Traverse

In other words, walk on the AST object.

Name Languages In this repository?
zimmerframe icon-jsicon-tsicon-svelte ❌

Analyze

Analyze the received AST object(s). Contains type-guards and utilities.

Name Languages In this repository?
js-ast-analyze icon-js βœ…
ts-ast-analyze icon-jsicon-ts βœ…
svelte-ast-analyze icon-jsicon-tsicon-svelte βœ…

Build

Sometimes you need to do some code transformation...

Name Languages In this repository?
js-ast-build icon-js βœ…
ts-ast-build icon-ts βœ…
svelte-ast-build icon-svelte βœ…

Print

Print the AST object or nodes into stringified code syntax.

Name Languages In this repository?
esrap icon-jsicon-ts ❌
svelte-ast-print icon-jsicon-tsicon-svelte βœ…

Contributing

If you can offer your time - refer to Contribution Guide.

Otherwise, consider sponsoring me.

Author

Mateusz "xeho91" Kadlubowski