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

taro 3.3.7 新建 vue3.0 项目 打包支付宝报错 #11133

Open
jiezai0920 opened this issue Jan 19, 2022 · 22 comments
Open

taro 3.3.7 新建 vue3.0 项目 打包支付宝报错 #11133

jiezai0920 opened this issue Jan 19, 2022 · 22 comments
Assignees
Labels
F-vue3 Framework - Vue 3 question Further information is requested T-alipay Target - 编译到支付宝小程序 V-3 Version - 3.x

Comments

@jiezai0920
Copy link

相关平台

支付宝小程序

复现仓库

https://github.com/jiezai0920/taro-test
小程序基础库: 2.0
使用框架: Vue 3

复现步骤

在项目根目录中运行yarn build:alipay,将打包好的dis文件在支付宝开发者工具中打开

期望结果

支付宝小程序可以正常运行

实际结果

报错
myApp1/dist/vendors.js: Unexpected token (2207:136)
Please set enableNodeModuleBabelTransform to true or add "myApp1/dist/vendors.js" to node_modules_es6_whitelist in mini.project.json for node_modules babel transform

环境信息

Taro v3.3.3


  Taro CLI 3.3.3 environment info:
    System:
      OS: macOS 10.15.5
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 16.4.0 - ~/.nvm/versions/node/v16.4.0/bin/node
      Yarn: 1.22.4 - ~/.yarn/bin/yarn
      npm: 7.18.1 - ~/.nvm/versions/node/v16.4.0/bin/npm
    npmPackages:
      @tarojs/components: 3.3.3 => 3.3.3
      @tarojs/mini-runner: 3.3.3 => 3.3.3
      @tarojs/runtime: 3.3.3 => 3.3.3
      @tarojs/taro: 3.3.3 => 3.3.3
      @tarojs/webpack-runner: 3.3.3 => 3.3.3
      babel-preset-taro: 3.3.3 => 3.3.3
      eslint-config-taro: 3.3.3 => 3.3.3
@taro-bot2 taro-bot2 bot added F-vue3 Framework - Vue 3 T-alipay Target - 编译到支付宝小程序 V-3 Version - 3.x labels Jan 19, 2022
@Chen-jj
Copy link
Contributor

Chen-jj commented Jan 19, 2022

升级最新版再试试

@jsjzh
Copy link

jsjzh commented Jan 19, 2022

同样的问题,也是 vue3.x,taro 已经全部升级到最新版本 3.4.0,node v14

并且发现,上传 alipay 时,preview 不会报错,upload 会报错,问了 alipay 的人说是 upload 开启了代码压缩,preview 没有,是压缩代码导致的报错信息,我已经到 alipay 那边要来了具体报错内容,如下所示

03:06:23.567 - Failed to compile

03:06:23.568 - 压缩代码时报错,请检查node_modules中是否使用了ES6语法, ES6代码会导致 iOS9/iOS10 运行时白屏

出错位置: /tmp/data/onetime_tmp_dir/951a8397-4536-4ae4-84c7-8173659c66d3-1642561571311/tiny-Gyfxe1Ouo-1642561571335/main/index.worker.js:647:67687
错误信息: index.worker.js from UglifyJs
Unexpected token: name «property», expected: punc «,» [./vendors.js:1,2][index.worker.js:647,67687]

@Chen-jj
Copy link
Contributor

Chen-jj commented Jan 23, 2022

@jiezai0920 楼主的代码我用 Taro 3.4 测试没有发现有报错额:

image

@Chen-jj
Copy link
Contributor

Chen-jj commented Jan 23, 2022

@jsjzh

  1. 如果有和楼主一样的问题,可以提供一下 Demo?这边没有复现
  2. 上传了个简单 Demo 进行测试也没有复现。看报错是说 vendor.js 有 ES6 语法的样子,可以先检查一下。Webpack splitchunks 配置了 vendor.js 是 node_modules 依赖,可能是某些依赖带有 ES6 语法,如果是这个问题,可以配置 babel-loader 去编译这些依赖。

@Chen-jj
Copy link
Contributor

Chen-jj commented Jan 23, 2022

#11142

@MarshallYang
Copy link

@Chen-jj 还是不可以,新建的项目, vue3 + typescript + sass + 默认模版
image
执行 yarn build:alipay, 支付宝运行
image
仍然提示 vendor.js 里面有问题。
支付宝小程序开发者工具版本:版本2.7.2 (2.7.2)

@sjx1995
Copy link

sjx1995 commented Mar 24, 2022

同样的错误
taro3.4.3,钉钉小程序,vue3模板,dev正常,build报错

@emaoxiongzhang
Copy link

同样的错误 taro3.4.3,钉钉小程序,vue3模板,dev正常,build报错

我在build命令 后面增加了 --watch解决了

@emaoxiongzhang
Copy link

也遇到这样的问题,选择vue3模板,dev正常,build报错

我在build命令 后面增加了 --watch解决了

@emaoxiongzhang
Copy link

@Chen-jj 还是不可以,新建的项目, vue3 + typescript + sass + 默认模版 image 执行 yarn build:alipay, 支付宝运行 image 仍然提示 vendor.js 里面有问题。 支付宝小程序开发者工具版本:版本2.7.2 (2.7.2)

我在build命令 后面增加了 --watch解决了"build:dd": "taro build --type dd --watch",

@emaoxiongzhang
Copy link

相关平台

支付宝小程序

复现仓库

https://github.com/jiezai0920/taro-test 小程序基础库: 2.0 使用框架: Vue 3

复现步骤

在项目根目录中运行yarn build:alipay,将打包好的dis文件在支付宝开发者工具中打开

期望结果

支付宝小程序可以正常运行

实际结果

报错 myApp1/dist/vendors.js: Unexpected token (2207:136) Please set enableNodeModuleBabelTransform to true or add "myApp1/dist/vendors.js" to node_modules_es6_whitelist in mini.project.json for node_modules babel transform

环境信息

Taro v3.3.3


  Taro CLI 3.3.3 environment info:
    System:
      OS: macOS 10.15.5
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 16.4.0 - ~/.nvm/versions/node/v16.4.0/bin/node
      Yarn: 1.22.4 - ~/.yarn/bin/yarn
      npm: 7.18.1 - ~/.nvm/versions/node/v16.4.0/bin/npm
    npmPackages:
      @tarojs/components: 3.3.3 => 3.3.3
      @tarojs/mini-runner: 3.3.3 => 3.3.3
      @tarojs/runtime: 3.3.3 => 3.3.3
      @tarojs/taro: 3.3.3 => 3.3.3
      @tarojs/webpack-runner: 3.3.3 => 3.3.3
      babel-preset-taro: 3.3.3 => 3.3.3
      eslint-config-taro: 3.3.3 => 3.3.3

我在build命令 后面增加了 --watch解决了"build:dd": "taro build --type dd --watch",

@duanxianze
Copy link

这个问题依旧存在啊 3.4.4版本

@Chen-jj
Copy link
Contributor

Chen-jj commented Apr 12, 2022

@jiezai0920 @jsjzh @MarshallYang @loong917 @sjx1995 @emaoxiongzhang @sjx1995 @duanxianze 各位提供一下编译信息?

image

尝试过【 Taro v3.4.4 + Vue3 NutUI 模板 + 支付宝开发者工具 v2.7.2 】打包生产模式代码:无论是支付宝还是钉钉模式,开发者工具都能正常编译显示;点击上传也没有报错,可以成功上传。因此还是不确定触发此问题的条件。

翻阅支付宝小程序文档,在小程序基础库 v2 中有提到此报错。然而尝试过开启或关闭小程序基础库 2.0 构建,都能正常编译。

image

报错原因应该是我之前提到的,存在 es6 的语法:

  1. 如果有和楼主一样的问题,可以提供一下 Demo?这边没有复现
  2. 上传了个简单 Demo 进行测试也没有复现。看报错是说 vendor.js 有 ES6 语法的样子,可以先检查一下。Webpack splitchunks 配置了 vendor.js 是 node_modules 依赖,可能是某些依赖带有 ES6 语法,如果是这个问题,可以配置 babel-loader 去编译这些依赖。

@Chen-jj Chen-jj self-assigned this Apr 12, 2022
@Chen-jj Chen-jj added the question Further information is requested label Apr 12, 2022
@duanxianze
Copy link

image

@duanxianze
Copy link

https://github.com/duanxianze/tarodemo
我的复现仓库 node 14.9 vue3 taro3.4.4

@Chen-jj
Copy link
Contributor

Chen-jj commented Apr 12, 2022

https://github.com/duanxianze/tarodemo 我的复现仓库 node 14.9 vue3 taro3.4.4

我这边可以。。

image

@duanxianze
Copy link

支付宝小程序开发工具 Version 2.7.2
我只能想到可能是这里的问题了。。

@duanxianze
Copy link

我把我运行build生成的dist也传上去了 您可以运行看下

@sjx1995
Copy link

sjx1995 commented Apr 13, 2022

image

@Chen-jj 我编译到钉钉小程序没有【启用小程序基础库2.0构建】的选项,现在使用 npm run build:dd -- --watch 编译可以暂时解决问题

@cys19970903
Copy link

cys19970903 commented Apr 19, 2022

支付宝小程序 config/index.js mini下增加以下配置问题解决

webpackChain(chain, webpack) {
      chain.merge({
        module: {
          rule: [
            {
              test: /.js$/,
              loader: "babel-loader",
            },
          ],
        },
      });
    },

@asvue
Copy link

asvue commented Apr 22, 2022

支付宝小程序 config/index.js mini下增加以下配置问题解决

webpackChain(chain, webpack) {
      chain.merge({
        module: {
          rule: [
            {
              test: /.js$/,
              loader: "babel-loader",
            },
          ],
        },
      });
    },

这个答案配上 watch 完美解决.谢谢大哥

@jerryyan1990
Copy link

支付宝小程序 config/index.js mini下增加以下配置问题解决

webpackChain(chain, webpack) {
      chain.merge({
        module: {
          rule: [
            {
              test: /.js$/,
              loader: "babel-loader",
            },
          ],
        },
      });
    },

感谢,使用这个方法暂时解决了。打包没问题了。但开发模式,预览和真机调试会出现找不到页面的情况,不知道为什么。支付宝模拟器正常无报错。真机调试有报错。
index.vue?db4f:9 TypeError: Cannot read property 'indexOf' of undefined at ../shared-utils/lib/env.js (index.worker.js:15:295378) at r (index.worker.js:15:296263) at index.worker.js:15:296774 at index.worker.js:15:296710 at ./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]/node_modules/@tarojs/plugin-vue-devtools/dist/backend/build/hook.js (index.worker.js:15:288930) at t (index.worker.js:3:79124) at ./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]/node_modules/@tarojs/plugin-vue-devtools/dist/backend/index.js (index.worker.js:15:297163) at t (index.worker.js:3:79124) at ./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]/node_modules/@tarojs/plugin-vue-devtools/dist/runtime.js (index.worker.js:15:301250) at t (index.worker.js:3:79124) at ./src/app.js (index.worker.js:3:85278) at t (index.worker.js:3:79124) at n (index.worker.js:3:97493) at index.worker.js:3:97555 at index.worker.js:3:79531 at index.worker.js:3:97575 at n (index.worker.js:3:80479) at GfhN (index.worker.js:3:81814) at t (index.worker.js:3:392) at r (index.worker.js:3:13643) at h (index.worker.js:13:4) at index.worker.js:15:55 at index.worker.js:3:15427 at 1Fxu (index.worker.js:3:13105) at t (index.worker.js:3:392) at 0 (index.worker.js:3:1584) at t (index.worker.js:3:392) at index.worker.js:3:1185 at index.worker.js:3:91 h @ index.vue?db4f:9 (anonymous) @ index.vue?db4f:9 (anonymous) @ index.vue?db4f:9 1Fxu @ index.vue?3e67:9 t @ index.vue?3e67:9 0 @ bootstrap:5 t @ rewrite-helper.js:31 (anonymous) @ bootstrap:5 (anonymous) @ index.worker.js:3 index.vue?db4f:9 Error: [🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"? See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help. This will fail in production. at s (index.worker.js:15:1258285) at ./src/hooks/useNeedLogin.js (index.worker.js:3:145822) at t (index.worker.js:3:79124) at ./node_modules/.pnpm/[email protected]/node_modules/unplugin/dist/webpack/loaders/transform.js?unpluginName=unplugin-auto-import!./node_modules/.pnpm/[email protected]/node_modules/unplugin/dist/webpack/loaders/transform.js?unpluginName=unplugin-vue-components!./node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/babel-loader/lib/index.js!./node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/babel-loader/lib/index.js??clonedRuleSet-12.use[0]!./node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/pages/index/index.vue?vue&type=script&setup=true&lang=js (index.worker.js:3:52223) at t (index.worker.js:3:79124) at ./src/pages/index/index.vue?vue&type=script&setup=true&lang=js (index.worker.js:3:70452) at t (index.worker.js:3:79124) at ./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]/node_modules/@tarojs/taro-loader/lib/raw.js!./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]/node_modules/@tarojs/taro-loader/lib/entry-cache.js?name=pages/index/index!./src/pages/index/index.vue (index.worker.js:3:38935) at t (index.worker.js:3:79124) at ./src/pages/index/index.vue (index.worker.js:3:69816) at t (index.worker.js:3:79124) at n (index.worker.js:3:75827) at index.worker.js:3:75889 at index.worker.js:3:79531 at index.worker.js:3:75924 at n (index.worker.js:3:80479) at 8x2U (index.worker.js:3:38440) at t (index.worker.js:3:392) at +3/E (index.worker.js:3:1246) at t (index.worker.js:3:392) at pages/index/index (index.worker.js:3:14291) at h (index.worker.js:13:4) at index.worker.js:15:55 at index.worker.js:3:15427 at 1Fxu (index.worker.js:3:13105) at t (index.worker.js:3:392) at 0 (index.worker.js:3:1584) at t (index.worker.js:3:392) at index.worker.js:3:1185 at index.worker.js:3:91 h @ index.vue?db4f:9 (anonymous) @ index.vue?db4f:9 (anonymous) @ index.vue?db4f:9 1Fxu @ index.vue?3e67:9 t @ index.vue?3e67:9 0 @ bootstrap:5 t @ rewrite-helper.js:31 (anonymous) @ bootstrap:5 (anonymous) @ index.worker.js:3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-vue3 Framework - Vue 3 question Further information is requested T-alipay Target - 编译到支付宝小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

10 participants