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

yarn dev:weapp运行报错:SyntaxError: Unexpected token export #7155

Closed
hoozi opened this issue Jul 24, 2020 · 3 comments
Closed

yarn dev:weapp运行报错:SyntaxError: Unexpected token export #7155

hoozi opened this issue Jul 24, 2020 · 3 comments
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@hoozi
Copy link

hoozi commented Jul 24, 2020

相关平台

微信小程序

复现仓库

git
小程序基础库: 2.11.2
使用框架: React

复现步骤

我在constants文件中定义了一个color json对象,
const color = {
brandColor: '#2d75ff',
brandColorTap: '#2a6ce8',
tintColor: '#fff',
textBaseColor: '#333B5A',
fillColor: '#f7f8fa',
borderColorBase: '#ebedf0',
warningColor: '#fa8c16',
successColor: '#6abf47',
errorColor: '#f4333c',
importantColor: '#ff5b05',
waitColor: '#108ee9'
}

export {
color
};

当运行yarn dev:weapp的时候,报错如下:
(node:20859) UnhandledPromiseRejectionWarning: /Users/leihu/Desktop/apply/client/src/constants/index.tsx:15
export {
^^^^^^

SyntaxError: Unexpected token export;

期望结果

实际结果

环境信息

Taro CLI 3.0.5 environment info:
    System:
      OS: macOS 10.14.6
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 12.4.0 - ~/.nvm/versions/node/v12.4.0/bin/node
      Yarn: 1.22.4 - ~/.nvm/versions/node/v12.4.0/bin/yarn
      npm: 6.14.5 - ~/.nvm/versions/node/v12.4.0/bin/npm
    npmPackages:
      @tarojs/components: 3.0.5 => 3.0.5 
      @tarojs/mini-runner: 3.0.5 => 3.0.5 
      @tarojs/react: 3.0.5 => 3.0.5 
      @tarojs/runtime: 3.0.5 => 3.0.5 
      @tarojs/taro: 3.0.5 => 3.0.5 
      @tarojs/webpack-runner: 3.0.5 => 3.0.5 
      babel-preset-taro: 3.0.5 => 3.0.5 
      eslint-config-taro: 3.0.5 => 3.0.5 
      react: ^16.10.0 => 16.13.1 
      taro-ui: ^3.0.0-alpha.3 => 3.0.0-alpha.3 

补充信息

我在别的项目里 也一直是这么export,taro中却不行,是我哪里姿势不对吗

@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Jul 24, 2020
@Chen-jj
Copy link
Contributor

Chen-jj commented Jul 27, 2020

@hoozi 给个 demo 看看吧。

@hoozi
Copy link
Author

hoozi commented Jul 27, 2020

@hoozi 给个 demo 看看吧。

找到问题了,在页面的config.ts里面 加了一个import,如下:

import { color } from '../../constants/color';

export default {
navigationBarTitleText: '详细信息',
navigationBarBackgroundColor: color.brandColor,
navigationBarTextStyle: 'white'
}

页面的config 不支持这种import吗?现在我把颜色直接写死了,之前是想统一在color里定义navigationBar颜色

@Chen-jj
Copy link
Contributor

Chen-jj commented Jul 27, 2020

目前没有做依赖分析,所以不支持。#7011

@Chen-jj Chen-jj closed this as completed Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

2 participants