ast-types icon indicating copy to clipboard operation
ast-types copied to clipboard

Add `@babel/template`-like package

Open fengzilong opened this issue 5 years ago • 5 comments

Write the builders syntax by hand is really tedious, can we provide some package like @babel/template or add an online playground to convert the code to builders syntax. It will save us tons of time

fengzilong avatar Oct 28 '19 05:10 fengzilong

@fengzilong Actually I am working on one playground to build AST nodes through code for jscodeshift and Glimmer templates here. https://rajasegar.github.io/ast-builder/ Please let me know this is what you are looking for. Appreciate any PRs or issues. And thanks for the @babel/template pointer btw. For this project, let's hear from @benjamn

rajasegar-c avatar Nov 15 '19 09:11 rajasegar-c

Yeah, good job, that's the playground I need, but there are some issues with yours

try this snippet

module.exports = {
  components: {
    'demo': demo
  }
}

the 'demo' becomes j.identifier('undefined')

and it seems not to be usable with es6 export syntax

some suggestion: it will be much better if we can format the code with prettier

thanks for reply @rajasegar-c

fengzilong avatar Nov 18 '19 05:11 fengzilong

@fengzilong Thanks for trying it out and reporting the issues. It's a bug I need to fix and yes formatting needs some work.

rajasegar avatar Dec 06 '19 11:12 rajasegar

Can you give me an example for the ES6 export you were trying, have you tried changing the parser to babel or babylon? Fixed the module.exports and formatting

rajasegar avatar Dec 07 '19 10:12 rajasegar

@rajasegar sorry for my late reply, I just see the notification from github. I tried and ES6 export has been fixed, and formatting works perfectly👍

fengzilong avatar Dec 16 '19 10:12 fengzilong