https://github.com/xeho91/js-ast
Do some fun with AST, using JavaScript.
https://github.com/xeho91/js-ast
ast javascript svelte typescript
Last synced: 3 months ago
JSON representation
Do some fun with AST, using JavaScript.
- Host: GitHub
- URL: https://github.com/xeho91/js-ast
- Owner: xeho91
- License: mit
- Created: 2024-06-29T02:19:00.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-19T05:37:38.000Z (3 months ago)
- Last Synced: 2025-04-19T10:32:36.398Z (3 months ago)
- Topics: ast, javascript, svelte, typescript
- Language: TypeScript
- Homepage: https://xeho91.github.io/js-ast/
- Size: 7.17 MB
- Stars: 12
- Watchers: 3
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# `js-ast`
This is a monorepo with packages to **boost the [DX]** of working with [AST] _(using [JavaScript] programming language)_ related to:
- ![JavaScript icon][icon-js] [JavaScript]
- ![TypeScript icon][icon-ts] [TypeScript]
- ![Svelte icon][icon-svelte] [Svelte]---
## Core goals
1. [DX] friendly.
1. **Cross-runtime** friendlyβπ this also means [ESM] only.
1. [e18e] friendly.
1. Extensive tests and benchmarks.---
## Packages
In order to work with AST, the following processes are recognized:
1. [Parsing](#parse) _stringified_ code syntax into [AST] object.
1. [Traversing](#traverse) the [AST] object.
1. [Analyzing](#analyze) the [AST] object(s).
1. [Building](#build) programmatically the [AST] node(s), or an entire object.
1. [Printing](#print) 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-js]![icon-ts] | β |
| [`svelte/compiler`] | ![icon-svelte] | β |### Traverse
In other words, _walk_ on the AST object.
| Name | Languages | In this repository? |
| --------------- | ---------------------------------- | ------------------- |
| [`zimmerframe`] | ![icon-js]![icon-ts]![icon-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-js]![icon-ts] | π§ |
| `svelte-ast-analyze` | ![icon-js]![icon-ts]![icon-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 the [AST] object or nodes into stringified code syntax.
| Name | Languages | In this repository? |
| -------------------- | ---------------------------------- | ------------------- |
| [`esrap`] | ![icon-js]![icon-ts] | β |
| [`svelte-ast-print`] | ![icon-js]![icon-ts]![icon-svelte] | β |---
## Contributing
If you can offer your time - refer to [Contribution Guide](/.github/CONTRIBUTING.md).
Otherwise, consider [sponsoring me](https://github.com/sponsors/xeho91).
## Author
Mateusz "[xeho91](https://github.com/xeho91)" Kadlubowski
[icon-js]: https://api.iconify.design/logos:javascript.svg
[icon-ts]: https://api.iconify.design/logos:typescript-icon-round.svg
[icon-svelte]: https://api.iconify.design/logos:svelte-icon.svg
[AST]: https://en.wikipedia.org/wiki/Abstract_syntax_tree
[DX]: https://en.wikipedia.org/wiki/User_experience#Developer_experience
[ESTree]: https://github.com/estree/estree
[e18e]: https://github.com/e18e/e18e
[ESM]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
[`js-ast-analyze`]: ./packages/js-ast-build
[`js-ast-build`]: ./packages/js-ast-build
[`svelte-ast-analyze`]: ./packages/js-ast-build
[`svelte-ast-build`]: ./packages/svelte-ast-build
[`svelte-ast-print`]: ./packages/svelte-ast-print
[`ts-ast-analyze`]: ./packages/js-ast-build
[`ts-ast-build`]: ./packages/ts-ast-build
[`@swc/core`]: https://github.com/swc-project/swc
[`svelte/compiler`]: https://github.com/sveltejs/svelte
[`zimmerframe`]: https://github.com/Rich-Harris/zimmerframe
[`esrap`]: https://github.com/sveltejs/esrap
[Svelte]: https://github.com/sveltejs/svelte
[TypeScript]: https://github.com/microsoft/TypeScript
[JavaScript]: https://en.wikipedia.org/wiki/JavaScript