How to use babel-plugin-transform-taroapi - 1 common examples

To help you get started, we’ve selected a few babel-plugin-transform-taroapi 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 NervJS / taro / packages / taro-cli / src / h5 / index.ts View on Github external
let importTaroComponentNode: t.ImportDeclaration
    let importNervNode: t.ImportDeclaration
    let importTaroNode: t.ImportDeclaration
    let renderClassMethodNode: t.ClassMethod
    let exportDefaultDeclarationNode: t.ExportDefaultDeclaration
    let exportNamedDeclarationPath: NodePath
    let componentClassName
    let needSetConfigFromHooks
    let configFromHooks

    const renderReturnStatementPaths: NodePath[] = []
    ast = babel.transformFromAst(ast, '', {
      plugins: [
        [require('babel-plugin-preval')],
        [require('babel-plugin-danger-remove-unused-import'), { ignore: ['@tarojs/taro', 'react', 'nervjs'] }],
        [require('babel-plugin-transform-taroapi').default, {
          apis: require(resolve.sync('@tarojs/taro-h5/dist/taroApis', { basedir: this.appPath })),
          packageName: '@tarojs/taro'
        }]
      ]
    }).ast

    const ClassDeclarationOrExpression = {
      enter (astPath: NodePath | NodePath) {
        const node = astPath.node
        if (!node.superClass) return
        if (isTaroClass(astPath)) {
          resetTSClassProperty(node.body.body)
          if (t.isClassDeclaration(astPath)) {
            if (node.id === null) {
              componentClassName = '_TaroComponentClass'
              astPath.replaceWith(

babel-plugin-transform-taroapi

用于 H5 端转换 import default Taro API 为模块化引用,以达到 tree-shaking 的目的。

MIT
Latest version published 20 days ago

Package Health Score

63 / 100
Full package analysis

Popular babel-plugin-transform-taroapi functions

Similar packages