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

Taro next升级后,编译报错 #5803

Closed weiTimes closed 4 years ago

weiTimes commented 4 years ago

问题描述

正在从Taro2.0升级至Taro next,babel已升级至babel7,执行npm run start后报错,没有通过编译。

复现步骤

/**
 * 这段注释后可以贴代码
 * 提供完整可复现的代码和整理好代码格式,有助于我们快速定位问题,节省你我时间
 * 代码提供不全或代码格式混乱的 issues 【有可能会被忽略】
 * 
 * 查看如何插入代码:https://coding.net/help/doc/project/markdown.html#i-5
 */
版本依赖
`
"devDependencies": {
    "@babel/core": "^7.9.0",
    "@babel/plugin-proposal-class-properties": "^7.0.0",
    "@babel/plugin-proposal-decorators": "^7.8.3",
    "@babel/plugin-proposal-object-rest-spread": "^7.0.0",
    "@babel/plugin-proposal-pipeline-operator": "^7.8.3",
    "@babel/plugin-syntax-dynamic-import": "^7.8.3",
    "@babel/plugin-transform-runtime": "^7.0.0",
    "@babel/plugin-transform-typescript": "^7.9.4",
    "@babel/preset-env": "^7.0.0",
    "@babel/preset-flow": "^7.9.0",
    "@babel/preset-react": "^7.9.4",
    "@babel/preset-typescript": "^7.9.0",
    "@tarojs/plugin-babel": "2.0.6",
    "@tarojs/plugin-csso": "2.0.6",
    "@tarojs/plugin-sass": "2.0.6",
    "@tarojs/plugin-uglifyjs": "2.0.6",
    "@tarojs/webpack-runner": "2.0.6",
    "@types/react": "^16.4.8",
    "@types/webpack-env": "^1.13.6",
    "babel-eslint": "^9.0.0",
    "babel-plugin-transform-jsx-stylesheet": "^0.6.5",
    "eslint": "^5.16.0",
    "eslint-config-taro": "2.0.6",
    "eslint-plugin-import": "^2.12.0",
    "eslint-plugin-react": "^7.8.2",
    "eslint-plugin-react-hooks": "^1.6.1",
    "eslint-plugin-taro": "2.0.6",
    "js-base64": "^2.5.1",
    "stylelint": "9.3.0",
    "stylelint-config-taro-rn": "2.0.6",
    "stylelint-taro-rn": "2.0.6",
    "taro-cropper": "^1.1.0",
    "webpack-bundle-analyzer": "^3.6.0"
  }
`
`babel.config.js`配置
`
const presets = [
  [
    "@babel/env",
    {
      useBuiltIns: "usage",
      corejs: {
        version: 2,
        proposals: true // 使用尚在“提议”阶段特性的 polyfill
      }
    }
  ],
  [
    "@babel/preset-react",
    {
      pragma: "dom", // default pragma is React.createElement
      pragmaFrag: "DomFrag", // default is React.Fragment
      throwIfNamespace: false, // defaults to true
      development: process.env.BABEL_ENV === "development"
    }
  ],
  [
    "@babel/preset-typescript",
    {
      allExtensions: true,
      isTSX: true
    }
  ],
  "@babel/preset-flow"
];

module.exports = {
  presets: presets,
  plugins: [
    [
      "@babel/plugin-transform-runtime",
      {
        corejs: 2
      }
    ],
    ["@babel/plugin-proposal-decorators", { legacy: true }],
    ["@babel/plugin-proposal-pipeline-operator", { proposal: "minimal" }],
    "@babel/plugin-syntax-dynamic-import",
    "@babel/plugin-proposal-object-rest-spread",
    "@babel/plugin-proposal-class-properties",
    "@babel/plugin-transform-typescript"
  ] // same as "@babel/plugin-transform-arrow-functions"
};

`

期望行为

希望可以编译通过

报错信息

终端编译报错信息

系统信息

 Taro v3.0.0-beta.1

  Taro CLI 3.0.0-beta.1 environment info:
    System:
      OS: macOS 10.15.3
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node
      Yarn: 1.22.4 - /usr/local/bin/yarn
      npm: 6.13.4 - ~/.nvm/versions/node/v12.16.1/bin/npm
    npmPackages:
      @tarojs/async-await: 2.0.6 => 2.0.6
      @tarojs/components: ^3.0.0-beta.1 => 3.0.0-experimental.5
      @tarojs/plugin-babel: 2.0.6 => 2.0.6
      @tarojs/plugin-csso: 2.0.6 => 2.0.6
      @tarojs/plugin-sass: 2.0.6 => 2.0.6
      @tarojs/plugin-uglifyjs: 2.0.6 => 2.0.6
      @tarojs/redux: 2.0.6 => 2.0.6
      @tarojs/redux-h5: 2.0.6 => 2.0.6
      @tarojs/router: 2.0.6 => 2.0.6
      @tarojs/taro: ^3.0.0-beta.1 => 3.0.0-experimental.5
      @tarojs/taro-alipay: 2.0.6 => 2.0.6
      @tarojs/taro-h5: 2.0.6 => 2.0.6
      @tarojs/taro-swan: 2.0.6 => 2.0.6
      @tarojs/taro-tt: 2.0.6 => 2.0.6
      @tarojs/taro-weapp: 2.0.6 => 2.0.6
      @tarojs/webpack-runner: 2.0.6 => 2.0.6
      eslint-config-taro: 2.0.6 => 2.0.6
      eslint-plugin-taro: 2.0.6 => 2.0.6
      nerv-devtools: ^1.5.6 => 1.5.6
      nervjs: ^1.5.6 => 1.5.6
      react: ^16.13.1 => 16.13.1
      stylelint-config-taro-rn: 2.0.6 => 2.0.6
      stylelint-taro-rn: 2.0.6 => 2.0.6

补充信息

如果您有功能上的建议,可以提到 FeatHub

使用上的问题,欢迎在「Taro 社区」一起交流

taro-bot[bot] commented 4 years ago

CC @luckyadam

taro-bot[bot] commented 4 years ago

欢迎提交 Issue~

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

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

Good luck and happy coding~

weiTimes commented 4 years ago

报错信息已经贴上,其中有两个地方,第一个是一直提示The code generator has deoptimised the styling of /Users/yewei/Project/banmatou/taro-lottery/node_modules/react-reconciler/cjs/react-reconciler.development.js as it exceeds the max of 500KB; 还有就是在编译到index.scss时报TypeError: __webpack_require__(...) is not a function,是不是升级到taron next后还需要配置loader呢?

weiTimes commented 4 years ago

希望可以帮忙尽快看一下,比较急,弄了快一天了。

yuche commented 4 years ago

你的依赖没有装 @tarojs/mini-runner 吗

weiTimes commented 4 years ago
{
  "name": "taro-find",
  "version": "1.0.0",
  "private": true,
  "description": "发现",
  "templateInfo": {
    "name": "redux",
    "typescript": false,
    "css": "sass"
  },
  "scripts": {
    "build:weapp": "taro build --type weapp",
    "build:swan": "taro build --type swan",
    "build:alipay": "taro build --type alipay",
    "build:tt": "taro build --type tt",
    "build:h5": "taro build --type h5",
    "build:rn": "taro build --type rn",
    "dev:weapp": "npm run build:weapp -- --watch",
    "start": "npm run build:weapp -- --watch",
    "dev:swan": "npm run build:swan -- --watch",
    "dev:alipay": "npm run build:alipay -- --watch",
    "dev:tt": "npm run build:tt -- --watch",
    "dev:h5": "npm run build:h5 -- --watch",
    "dev:rn": "npm run build:rn -- --watch"
  },
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@babel/runtime-corejs2": "^7.0.0",
    "@tarojs/async-await": "2.0.6",
    "@tarojs/components": "^3.0.0-beta.1",
    "@tarojs/mini-runner": "^3.0.0-beta.1", //  **在这里**
    "@tarojs/react": "^3.0.0-beta.1",
    "@tarojs/redux": "2.0.6",
    "@tarojs/redux-h5": "2.0.6",
    "@tarojs/router": "2.0.6",
    "@tarojs/runtime": "^3.0.0-beta.1",
    "@tarojs/taro": "^3.0.0-beta.1",
    "@tarojs/taro-alipay": "2.0.6",
    "@tarojs/taro-h5": "2.0.6",
    "@tarojs/taro-swan": "2.0.6",
    "@tarojs/taro-tt": "2.0.6",
    "@tarojs/taro-weapp": "2.0.6",
    "dva-core": "^2.0.0",
    "dva-loading": "^3.0.15",
    "moment": "^2.24.0",
    "mp-colorui": "^0.5.10",
    "nerv-devtools": "^1.5.6",
    "nervjs": "^1.5.6",
    "query-string": "^6.8.3",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "redux": "^4.0.5",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.3.0",
    "taro-listview": "^1.1.11",
    "taro-ui": "^2.2.4",
    "utilscore": "^0.0.45"
  },
  "devDependencies": {
    "@babel/core": "^7.9.0",
    "@babel/plugin-proposal-class-properties": "^7.0.0",
    "@babel/plugin-proposal-decorators": "^7.8.3",
    "@babel/plugin-proposal-object-rest-spread": "^7.0.0",
    "@babel/plugin-proposal-pipeline-operator": "^7.8.3",
    "@babel/plugin-syntax-dynamic-import": "^7.8.3",
    "@babel/plugin-transform-runtime": "^7.0.0",
    "@babel/plugin-transform-typescript": "^7.9.4",
    "@babel/preset-env": "^7.0.0",
    "@babel/preset-flow": "^7.9.0",
    "@babel/preset-react": "^7.9.4",
    "@babel/preset-typescript": "^7.9.0",
    "@tarojs/plugin-babel": "2.0.6",
    "@tarojs/plugin-csso": "2.0.6",
    "@tarojs/plugin-sass": "2.0.6",
    "@tarojs/plugin-uglifyjs": "2.0.6",
    "@tarojs/webpack-runner": "2.0.6",
    "@types/react": "^16.4.8",
    "@types/webpack-env": "^1.13.6",
    "babel-eslint": "^9.0.0",
    "babel-plugin-transform-jsx-stylesheet": "^0.6.5",
    "eslint": "^5.16.0",
    "eslint-config-taro": "2.0.6",
    "eslint-plugin-import": "^2.12.0",
    "eslint-plugin-react": "^7.8.2",
    "eslint-plugin-react-hooks": "^1.6.1",
    "eslint-plugin-taro": "2.0.6",
    "js-base64": "^2.5.1",
    "stylelint": "9.3.0",
    "stylelint-config-taro-rn": "2.0.6",
    "stylelint-taro-rn": "2.0.6",
    "taro-cropper": "^1.1.0",
    "webpack": "^4.42.1",
    "webpack-bundle-analyzer": "^3.6.0"
  }
}
weiTimes commented 4 years ago

安装在 dependencies中

yuche commented 4 years ago

应该是 mp-colorui 还没有适配 taro next

weiTimes commented 4 years ago

我等会先把mp-colorui移除了试试,一直提示这个The code generator has deoptimised the styling of /Users/yewei/Project/banmatou/taro-lottery/node_modules/react-reconciler/cjs/react-reconciler.development.js as it exceeds the max of 500KB和这是一个问题吗

weiTimes commented 4 years ago

image 移除了mp-colorui 后,taro-cropper也报这个错了,不会第三方库都有问题吧,我感觉是不是scss解析的问题,这里都是解析到scss文件报错。

yuche commented 4 years ago

因为 taro-cropper 也没有适配 taro next,scss 也是一个问题,按理来说 scss 文件不应该放在 dist 里,即便你解决了 scss 问题,这些包没有适配也是编译不了的

weiTimes commented 4 years ago

这样啊,那算是白忙活了,看来这个项目是没法升级到next了

taro-bot[bot] commented 4 years ago

Hello~

您的问题楼上已经有了确切的回答,如果没有更多的问题这个 issue 将在 15 天后被自动关闭。

如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。

Good luck and happy coding~

331000738 commented 4 years ago

同问

sushiGump commented 4 years ago

这应该是taro-ui版本要升级到3x以上,taro-ui2x和taro next不兼容