How to use better-babel-generator - 10 common examples

To help you get started, we’ve selected a few better-babel-generator 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 Tencent / omi / packages / omip / my-app / scripts / taro-cli / src / h5.js View on Github external
if (hasJSX && !hasAddNervJsImportDefaultName) {
          //@fix
          // node.body.unshift(
          //   t.importDeclaration([
          //     t.importDefaultSpecifier(t.identifier(nervJsImportDefaultName))
          //   ], t.stringLiteral(PACKAGES['nervjs']))
          // )
        }
        if (taroImportDefaultName) {
          const importTaro = toAst(`import ${taroImportDefaultName} from '${PACKAGES['@tarojs/taro-h5']}'`)
          node.body.unshift(importTaro)
        }
      }
    }
  })
  const generateCode = generate(ast, {
    jsescOption: {
      minimal: true
    }
  }).code
  return {
    code: generateCode,
    ast
  }
}
github Tencent / omi / packages / cax-omip / scripts / taro-cli / src / h5.js View on Github external
if (hasJSX && !hasAddNervJsImportDefaultName) {
          //@fix
          // node.body.unshift(
          //   t.importDeclaration([
          //     t.importDefaultSpecifier(t.identifier(nervJsImportDefaultName))
          //   ], t.stringLiteral(PACKAGES['nervjs']))
          // )
        }
        if (taroImportDefaultName) {
          const importTaro = toAst(`import ${taroImportDefaultName} from '${PACKAGES['@tarojs/taro-h5']}'`)
          node.body.unshift(importTaro)
        }
      }
    }
  })
  const generateCode = generate(ast, {
    jsescOption: {
      minimal: true
    }
  }).code
  return {
    code: generateCode,
    ast
  }
}
github Tencent / omi / packages / omip / my-app-ts / scripts / taro-cli / src / h5.js View on Github external
//@fix
          //extraNodes.unshift(importNervjsNode)
        }
        if (tabBar) {
          extraNodes.unshift(importComponentNode)
        }

        lastImportNode.insertAfter(extraNodes)
        if (renderCallCode) {
          const renderCallNode = toAst(renderCallCode)
          astPath.pushContainer('body', renderCallNode)
        }
      }
    }
  })
  const generateCode = generate(ast, {
    jsescOption: {
      minimal: true
    }
  }).code
  return {
    code: generateCode,
    ast
  }
}
github Tencent / omi / packages / omip / taro-cli / src / util / ast_convert.js View on Github external
function generateMinimalEscapeCode (ast) {
  return generate(ast, {
    jsescOption: {
      minimal: true
    }
  }).code
}
github Tencent / omi / packages / cax-omip / scripts / taro-cli / src / h5.js View on Github external
//@fix
          //extraNodes.unshift(importNervjsNode)
        }
        if (tabBar) {
          extraNodes.unshift(importComponentNode)
        }

        lastImportNode.insertAfter(extraNodes)
        if (renderCallCode) {
          const renderCallNode = toAst(renderCallCode)
          astPath.pushContainer('body', renderCallNode)
        }
      }
    }
  })
  const generateCode = generate(ast, {
    jsescOption: {
      minimal: true
    }
  }).code
  return {
    code: generateCode,
    ast
  }
}
github Tencent / omi / packages / omip / taro-cli / src / h5.js View on Github external
if (hasJSX && !hasAddNervJsImportDefaultName) {
          extraNodes.unshift(importNervjsNode)
        }
        if (tabBar) {
          extraNodes.unshift(importComponentNode)
        }

        lastImportNode.insertAfter(extraNodes)
        if (renderCallCode) {
          const renderCallNode = toAst(renderCallCode)
          astPath.pushContainer('body', renderCallNode)
        }
      }
    }
  })
  const generateCode = generate(ast, {
    jsescOption: {
      minimal: true
    }
  }).code
  return {
    code: generateCode,
    ast
  }
}
github Tencent / omi / packages / omip / my-app / scripts / taro-cli / src / h5.js View on Github external
enter (astPath) {
        const node = astPath.node
        const callee = node.callee
        const calleeName = callee.name
        const parentPath = astPath.parentPath

        if (t.isMemberExpression(callee)) {
          if (callee.object.name === taroImportDefaultName && callee.property.name === 'render') {
            callee.object.name = nervJsImportDefaultName
            renderCallCode = generate(astPath.node).code
            astPath.remove()
          }
        } else {
          if (calleeName === setStoreFuncName) {
            if (parentPath.isAssignmentExpression() ||
              parentPath.isExpressionStatement() ||
              parentPath.isVariableDeclarator()) {
              parentPath.remove()
            }
          }
        }
      }
    },
github Tencent / omi / packages / omip / taro-cli / src / h5.js View on Github external
enter (astPath) {
        const node = astPath.node
        const callee = node.callee
        const calleeName = callee.name
        const parentPath = astPath.parentPath

        if (t.isMemberExpression(callee)) {
          if (callee.object.name === taroImportDefaultName && callee.property.name === 'render') {
            callee.object.name = nervJsImportDefaultName
            renderCallCode = generate(astPath.node).code
            astPath.remove()
          }
        } else {
          if (calleeName === setStoreFuncName) {
            if (parentPath.isAssignmentExpression() ||
              parentPath.isExpressionStatement() ||
              parentPath.isVariableDeclarator()) {
              parentPath.remove()
            }
          }
        }
      }
    },
github Tencent / omi / packages / omip / my-app / scripts / taro-cli / src / h5.js View on Github external
//@fix
          //extraNodes.unshift(importNervjsNode)
        }
        if (tabBar) {
          extraNodes.unshift(importComponentNode)
        }

        lastImportNode.insertAfter(extraNodes)
        if (renderCallCode) {
          const renderCallNode = toAst(renderCallCode)
          astPath.pushContainer('body', renderCallNode)
        }
      }
    }
  })
  const generateCode = generate(ast, {
    jsescOption: {
      minimal: true
    }
  }).code
  return {
    code: generateCode,
    ast
  }
}
github NervJS / taro / packages / taro-cli / src / h5 / index.ts View on Github external
const generateCode = (ast) => {
      return generate(ast, {
        jsescOption: {
          minimal: true
        }
      }).code
    }

better-babel-generator

Turns an AST into code.

MIT
Latest version published 5 years ago

Package Health Score

69 / 100
Full package analysis

Popular better-babel-generator functions

Similar packages