Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use swc to expose an AST to the runtime #3983

Closed
kitsonk opened this issue Feb 13, 2020 · 3 comments
Closed

Use swc to expose an AST to the runtime #3983

kitsonk opened this issue Feb 13, 2020 · 3 comments
Labels
cli related to cli/ dir feat new feature (which has been agreed to/accepted)

Comments

@kitsonk
Copy link
Contributor

kitsonk commented Feb 13, 2020

We include the swc crate as part of the dprint crate in order to power deno fmt. We should consider exposing swc to provide a runtime AST for JavaScript and TypeScript files. While we can't use the AST (yet) to drive the compiler, it would be a useful API to have in runtime to enable innovative solutions, like AST manipulation.

@axetroy
Copy link
Contributor

axetroy commented Feb 13, 2020

This APIs should be helpful for code Transform/style lint and more.

No need to rely on node.js

But I think it might be better to expose the typescript APIs

typescript provides a series of AST operations

@kitsonk
Copy link
Contributor Author

kitsonk commented Feb 13, 2020

typescript provides a series of AST operations

But the AST is not serializeable (see: microsoft/TypeScript#33502)... it is highly self referential and it is not really that easy to work with compared to things like estree like ASTs. I don't know what sort of AST swc generates, but it is worth looking at. If it is easy to serialize to JSON, then it will be better, and longer term Ry and I have talked about taking that AST and feeding it to the compiler, because the parsing is orders of magnitude faster than the compiler. So starting to work with it in the runtime helps us all start to move that direction.

@bartlomieju
Copy link
Member

#2355 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli related to cli/ dir feat new feature (which has been agreed to/accepted)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants