Put this plugin after the plugin you're debugging to see how it transformed your code.
Last active
August 6, 2021 18:53
-
-
Save dac09/71a29dfc920406ee7c9a28588c0dcfa3 to your computer and use it in GitHub Desktop.
Babel debugging plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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