How to use the @babel/template/lib/parse.default function in @babel/template

To help you get started, we’ve selected a few @babel/template examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xtuc / webassemblyjs / .babelrc.js View on Github external
function defineMacro(ident, body) {
    let content = '';

    if (t.isStringLiteral(body)) {
      content = body.value;
    }

    // Just merge elements
    if (t.isTemplateLiteral(body)) {
      content = body.quasis.reduce((acc, e) => {
        acc += e.value.raw;
        return acc;
      }, '');
    }

    const {placeholderNames} = parseAndBuildMetadata(smartFormater, content, {});

    macroMap[ident.name] = {
      run: template.smart(content),
      placeholderNames,
    }
  }