Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xeho91/js-ast
Do some fun with AST, using JavaScript.
https://github.com/xeho91/js-ast
ast print svelte
Last synced: 6 days 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 (8 months ago)
- Default Branch: main
- Last Pushed: 2025-02-05T14:50:34.000Z (9 days ago)
- Last Synced: 2025-02-05T15:45:41.063Z (9 days ago)
- Topics: ast, print, svelte
- Language: TypeScript
- Homepage: https://xeho91.github.io/svelte-ast-print/
- Size: 3.96 MB
- Stars: 11
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.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. **No build step**βmeaning you can debug/edit source code inside `node_modules` as it is.
1. Extensive tests.---
## Packages
In order to work with AST, the following processes are recognized:
1. [Building](#build) programmatically the [AST] node(s), or an entire object.
1. [Parsing](#parse) _stringified_ code syntax into [AST] object.
1. [Traversing](#traverse) the [AST] 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.### 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] | β |### 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] | β |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-build`]: ./pkgs/js-ast-build
[`ts-ast-build`]: ./pkgs/ts-ast-build
[`svelte-ast-build`]: ./pkgs/svelte-ast-build
[`svelte-ast-print`]: ./pkgs/svelte-ast-print
[`@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