Mirror: The magical sticky regex-based parser generator 馃
1import { makeHelpers } from './transform'; 2 3export default function reghexPlugin(babel, opts = {}) { 4 let helpers; 5 6 return { 7 name: 'reghex', 8 visitor: { 9 Program() { 10 helpers = makeHelpers(babel); 11 }, 12 ImportDeclaration(path) { 13 if (opts.codegen === false) return; 14 helpers.updateImport(path); 15 }, 16 TaggedTemplateExpression(path) { 17 if (helpers.isMatch(path) && helpers.getMatchImport(path)) { 18 if (opts.codegen === false) { 19 helpers.minifyMatch(path); 20 } else { 21 helpers.transformMatch(path); 22 } 23 } 24 }, 25 }, 26 }; 27}