Skip to content

Can @babel/types generate statements from source? #11996

Answered by JLHwung
shadowtime2000 asked this question in Q&A
Discussion options

You must be logged in to vote

Babel supports AST templates in @babel/template

import template from "@babel/template"
const ast = template.ast(`
  console.log('It works!')
`);

The ast is then a CallExpression.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@shadowtime2000
Comment options

@shadowtime2000
Comment options

Answer selected by shadowtime2000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #11996 on August 24, 2020 15:08.