Skip to content

Instantly share code, notes, and snippets.

@dac09
Last active August 6, 2021 18:53
Show Gist options
  • Save dac09/71a29dfc920406ee7c9a28588c0dcfa3 to your computer and use it in GitHub Desktop.
Save dac09/71a29dfc920406ee7c9a28588c0dcfa3 to your computer and use it in GitHub Desktop.
Babel debugging plugin

Put this plugin after the plugin you're debugging to see how it transformed your code.

// add import statement
// import generate from '@babel/generator'
// Use whole thing, including square brackets
[
function dannysLoggerBabelPlugin() {
console.log('running')
return {
name: 'debug-plugin',
visitor: {
Program(p, options) {
console.log('Transforming:', options.filename)
console.log(generate(p.node).code)
console.log('-'.repeat(50))
},
},
}
},
undefined,
'debug-plugin-danny-logger',
],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment