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

defineConstants不能定义为config的key? #2805

Closed
froyo-naux opened this issue Apr 17, 2019 · 2 comments
Closed

defineConstants不能定义为config的key? #2805

froyo-naux opened this issue Apr 17, 2019 · 2 comments

Comments

@froyo-naux
Copy link

问题描述
config/dev.js 的defineConstants定义个config的,yarn dev:weapp直接报错. yarn dev:h5没问题

复现步骤
[复现问题的步骤]

  1. taro init demo (选择typescript)
  2. config/dev.js
module.exports = {
  env: {
    NODE_ENV: '"development"'
  },
  defineConstants: {
    config: '"a"'
  },
  weapp: {},
  h5: {}
};
  1. yarn dev:weapp
  2. see error
编译  入口文件  src/app.tsx
{ TypeError: unknown: Property property of MemberExpression expected node to be of a type ["Identifier"] but instead got "StringLiteral"
    at validate (/Users/new/.nvm/versions/node/v8.11.3/lib/node_modules/@tarojs/cli/node_modules/babel-types/lib/definitions/index.js:109:13)
    at Object.validate (/Users/new/.nvm/versions/node/v8.11.3/lib/node_modules/@tarojs/cli/node_modules/babel-types/lib/definitions/core.js:412:50)
    at Object.validate (/Users/new/.nvm/versions/node/v8.11.3/lib/node_modules/@tarojs/cli/node_modules/babel-types/lib/index.js:505:9)
    at NodePath._replaceWith (/Users/new/.nvm/versions/node/v8.11.3/lib/node_modules/@tarojs/cli/node_modules/babel-traverse/lib/path/replacement.js:176:7)
    at NodePath.replaceWith (/Users/new/.nvm/versions/node/v8.11.3/lib/node_modules/@tarojs/cli/node_modules/babel-traverse/lib/path/replacement.js:160:8)
    at replaceAndEvaluateNode (/Users/new/.nvm/versions/node/v8.11.3/lib/node_modules/@tarojs/cli/node_modules/babel-plugin-transform-define/lib/index.js:117:12)
    at processNode (/Users/new/.nvm/versions/node/v8.11.3/lib/node_modules/@tarojs/cli/node_modules/babel-plugin-transform-define/lib/index.js:143:5)
    at PluginPass.Identifier (/Users/new/.nvm/versions/node/v8.11.3/lib/node_modules/@tarojs/cli/node_modules/babel-plugin-transform-define/lib/index.js:23:9)
    at newFn (/Users/new/.nvm/versions/node/v8.11.3/lib/node_modules/@tarojs/cli/node_modules/babel-traverse/lib/visitors.js:276:21)
    at NodePath._call (/Users/new/.nvm/versions/node/v8.11.3/lib/node_modules/@tarojs/cli/node_modules/babel-traverse/lib/path/context.js:76:18) _babel: true }
编译  所有页面
(node:94127) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'pages' of undefined
    at buildPages (/Users/new/.nvm/versions/node/v8.11.3/lib/node_modules/@tarojs/cli/src/weapp.js:1194:27)
    at Object.build (/Users/new/.nvm/versions/node/v8.11.3/lib/node_modules/@tarojs/cli/src/weapp.js:2230:9)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
    at Function.Module.runMain (module.js:695:11)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3
(node:94127) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:94127) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✨  Done in 7.17s.

期望行为
dev:weapp可以使用config这个常量。 目前换了个名字

系统信息

 Taro v1.2.26


  Taro CLI 1.2.26 environment info:
    System:
      OS: macOS 10.14.3
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node
      Yarn: 1.15.2 - /usr/local/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v8.11.3/bin/npm
    npmPackages:
      @tarojs/async-await: 1.2.26 => 1.2.26
      @tarojs/components: 1.2.26 => 1.2.26
      @tarojs/plugin-babel: 1.2.26 => 1.2.26
      @tarojs/plugin-csso: 1.2.26 => 1.2.26
      @tarojs/plugin-sass: 1.2.26 => 1.2.26
      @tarojs/plugin-uglifyjs: 1.2.26 => 1.2.26
      @tarojs/redux: 1.2.26 => 1.2.26
      @tarojs/redux-h5: 1.2.26 => 1.2.26
      @tarojs/router: 1.2.26 => 1.2.26
      @tarojs/taro: 1.2.26 => 1.2.26
      @tarojs/taro-alipay: 1.2.26 => 1.2.26
      @tarojs/taro-h5: 1.2.26 => 1.2.26
      @tarojs/taro-swan: 1.2.26 => 1.2.26
      @tarojs/taro-tt: 1.2.26 => 1.2.26
      @tarojs/taro-weapp: 1.2.26 => 1.2.26
      @tarojs/webpack-runner: 1.2.26 => 1.2.26
      eslint-config-taro: 1.2.26 => 1.2.26
      eslint-plugin-taro: 1.2.26 => 1.2.26
      nervjs: ^1.3.9 => 1.3.13
    npmGlobalPackages:
      typescript: 3.0.3
@taro-bot
Copy link

taro-bot bot commented Apr 17, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@froyo-naux
Copy link
Author

definePlugin的原理就是这样,自己的问题

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