2021-04-13 22:41:22 +02:00

28 lines
581 B
JavaScript

const register = require('../../..');
// Plugin to add '/* transformed */' comment to start of function bodies
const plugin = () => ( {
visitor: {
Function(path) {
const bodyNode = path.node.body;
(bodyNode.leadingComments || (bodyNode.leadingComments = [])).push( {
type: 'CommentBlock',
value: ' transformed '
} );
},
},
} );
register( {
ignore: [],
babelrc: false,
configFile: false,
plugins: [plugin]
} );
console.log(
JSON.stringify({
convertSourceMap: require('convert-source-map').fromObject.toString()
})
);