Replicating @babel/template functionality #3464
-
Hi there! I have a custom babel plugin that currently uses the const createPlugin = () => {
// The console.logs are just placeholders, the actual code is quite long
// I'd like to avoid manually rewriting into ASTs if possible
const beforeAst = babelTemplate.ast(`console.log('hi!')`)
const afterAst = babelTemplate.ast(`console.log('bye!')`)
return () => ({
visitor: {
Program: {
exit: (path) => {
path.unshiftContainer('body', beforeAst)
path.pushContainer('body', afterAst)
},
},
},
})
} I'd love to migrate it over to swc for those sweet performance gains, but after looking through the docs, I'm still unsure how I could accomplish the same task. Any assistance would be very much appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Alternative for |
Beta Was this translation helpful? Give feedback.
-
@kdy1 |
Beta Was this translation helpful? Give feedback.
Alternative for
@babel/template
is WIP.