Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

引用 graphql-tag 后编译失败 #926

Closed
wise199403 opened this issue Oct 24, 2018 · 0 comments
Closed

引用 graphql-tag 后编译失败 #926

wise199403 opened this issue Oct 24, 2018 · 0 comments

Comments

@wise199403
Copy link

问题描述
从 graphql-tag 导入 gql 函数导致编译失败。

复现步骤

安装依赖:
yarn add graphql graphql-tag

/src/pages/index/index.js 添加:

import gql from 'graphql-tag'

gql`
  {
    rates(currency: "USD") {
      currency
    }
  }
`

执行:
yarn run dev:weapp

得到错误信息。

期望行为
编译成功,无报错

报错信息

错误  页面编译  页面/Users/myName/Documents/Tmp/taro-demo/src/pages/index/index编译失败!
TypeError: Property quasi of TaggedTemplateExpression expected node to be of a type ["TemplateLiteral"] but instead got "StringLiteral"
    at Object.validate (/Users/myName/.config/yarn/global/node_modules/babel-types/lib/definitions/index.js:109:13)
    at Object.validate (/Users/myName/.config/yarn/global/node_modules/babel-types/lib/index.js:505:9)
    at NodePath._replaceWith (/Users/myName/.config/yarn/global/node_modules/babel-traverse/lib/path/replacement.js:176:7)
    at NodePath.replaceWith (/Users/myName/.config/yarn/global/node_modules/babel-traverse/lib/path/replacement.js:160:8)
    at TemplateLiteral (/Users/myName/.config/yarn/global/node_modules/@tarojs/transformer-wx/lib/src/index.js:198:18)
    at NodePath._call (/Users/myName/.config/yarn/global/node_modules/babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (/Users/myName/.config/yarn/global/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (/Users/myName/.config/yarn/global/node_modules/babel-traverse/lib/path/context.js:105:12)
    at TraversalContext.visitQueue (/Users/myName/.config/yarn/global/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitSingle (/Users/myName/.config/yarn/global/node_modules/babel-traverse/lib/context.js:108:19)

或者:

错误  页面编译  页面/Users/myName/Documents/Tmp/taro-demo/src/pages/index/index编译失败!
TypeError: Cannot read property 'wxss' of undefined
    at buildDepComponentsResult.map.item (/Users/myName/.config/yarn/global/node_modules/@tarojs/cli/src/weapp.js:1424:23)
    at Array.map (<anonymous>)
    at getDepStyleList (/Users/myName/.config/yarn/global/node_modules/@tarojs/cli/src/weapp.js:1423:44)
    at buildSinglePage (/Users/myName/.config/yarn/global/node_modules/@tarojs/cli/src/weapp.js:1265:28)

系统信息

  • 操作系统: macOS 10.13.4
  • Taro 版本: v1.1.0-beta.10
  • Node.js 版本: v10.8.0
  • 报错平台: weapp

补充信息

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant