NervJS / taro

开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
https://docs.taro.zone/
Other
35.6k stars 4.8k forks source link

引入第三方包,yarn run dev:swan时,出现错误:Property id of VariableDeclarator expected node to be of a type ["LVal"] but instead got "StringLiteral" #7693

Open hongxinfeiyang opened 4 years ago

hongxinfeiyang commented 4 years ago

相关平台

百度小程序

小程序基础库: 也版本无关 使用框架: React

复现步骤

安装第三方包 @baidu/ug-swan-utils 然后执行 yarn run dev:swan

报错如下: taro2-test/node_modules/@baidu/ug-swan-utils/dist/index.js: Property id of VariableDeclarator expected node to be of a type ["LVal"] but instead got "StringLiteral"

at Object.validate (/taro2-test/node_modules/babel-types/lib/definitions/index.js:109:13)
at Object.validate (/taro2-test/node_modules/babel-types/lib/index.js:505:9)
at NodePath._replaceWith (/taro2-test/node_modules/babel-traverse/lib/path/replacement.js:176:7)
at NodePath.replaceWith (/taro2-test/node_modules/babel-traverse/lib/path/replacement.js:160:8)
at replaceAndEvaluateNode (/taro2-test/node_modules/babel-plugin-transform-define/lib/index.js:117:12)
at processNode (/taro2-test/node_modules/babel-plugin-transform-define/lib/index.js:143:5)
at PluginPass.Identifier (/taro2-test/node_modules/babel-plugin-transform-define/lib/index.js:23:9)
at newFn (taro2-test/node_modules/babel-traverse/lib/visitors.js:276:21)
at NodePath._call (/taro2-test/node_modules/babel-traverse/lib/path/context.js:76:18)
at NodePath.call (/taro2-test/node_modules/babel-traverse/lib/path/context.js:48:17)
at NodePath.visit (/taro2-test/node_modules/babel-traverse/lib/path/context.js:105:12)
at TraversalContext.visitQueue (/taro2-test/node_modules/babel-traverse/lib/context.js:150:16)
at TraversalContext.visitSingle (/taro2-test/node_modules/babel-traverse/lib/context.js:108:19)
at TraversalContext.visit (/taro2-test/node_modules/babel-traverse/lib/context.js:192:19)
at Function.traverse.node (/taro2-test/node_modules/babel-traverse/lib/index.js:114:17)
at NodePath.visit (/taro2-test/node_modules/babel-traverse/lib/path/context.js:115:19) _babel: true }

🙅 编译失败.

./node_modules/@baidu/ug-swan-utils/dist/index.js Module Error (from ./node_modules/@tarojs/mini-runner/dist/loaders/wxTransformerLoader.js):

/taro2-test/node_modules/@baidu/ug-swan-utils/dist/index.js: Property id of VariableDeclarator expected node to be of a type ["LVal"] but instead got "StringLiteral"

期望结果

不会报这种类型错误

实际结果

出现报类型错误:Property id of VariableDeclarator expected node to be of a type ["LVal"] but instead got "StringLiteral"

环境信息

Taro CLI 2.2.14 environment info:
    System:
      OS: macOS High Sierra 10.13.4
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.14.2 - /usr/local/bin/node
      Yarn: 1.22.5 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
    npmPackages:
      @tarojs/components: 2.2.14 => 2.2.14
      @tarojs/components-qa: 2.2.14 => 2.2.14
      @tarojs/mini-runner: 2.2.14 => 2.2.14
      @tarojs/plugin-sass: 2.2.14 => 2.2.14
      @tarojs/plugin-terser: 2.2.14 => 2.2.14
      @tarojs/router: 2.2.14 => 2.2.14
      @tarojs/taro: 2.2.14 => 2.2.14
      @tarojs/taro-alipay: 2.2.14 => 2.2.14
      @tarojs/taro-h5: 2.2.14 => 2.2.14
      @tarojs/taro-qq: 2.2.14 => 2.2.14
      @tarojs/taro-quickapp: 2.2.14 => 2.2.14
      @tarojs/taro-rn: 2.2.14 => 2.2.14
      @tarojs/taro-swan: 2.2.14 => 2.2.14
      @tarojs/taro-tt: 2.2.14 => 2.2.14
      @tarojs/taro-weapp: 2.2.14 => 2.2.14
      @tarojs/webpack-runner: 2.2.14 => 2.2.14
      eslint-config-taro: 2.2.14 => 2.2.14
      eslint-plugin-taro: 2.2.14 => 2.2.14
      nerv-devtools: ^1.5.7 => 1.5.7
      nervjs: ^1.5.7 => 1.5.7
      stylelint-config-taro-rn: 2.2.14 => 2.2.14
      stylelint-taro-rn: 2.2.14 => 2.2.14
xianguoGou commented 1 year ago

I also encountered this problem

yoyo837 commented 1 year ago

盲猜一下 @baidu/ug-swan-utils 未适配 Taro?