Taro: 使用taro新建一个项目引用taro-ui组件 dev编译时开发工具不报错 build时开发工具报错

Created on 24 Oct 2020  ·  21Comments  ·  Source: NervJS/taro


相关平台

微信小程序

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

复现步骤

使用2.2.15版本taro初始化一个项目然后下载taro-ui 用npm run build:weapp进行编译 编译成功 开发者工具报错

期望结果

期望解决报错

实际结果

VM118:1 SystemError (jsEnginScriptError)
Component is not found in path "npm/taro-ui/dist/weapp/components/button/index" (using by "pages/index/index")
Error: Component is not found in path "npm/taro-ui/dist/weapp/components/button/index" (using by "pages/index/index")

环境信息

Taro CLI 2.2.15 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 12.19.0 - D:\Downloads\nodejs\node.EXE
      Yarn: 1.22.10 - C:\Users\wkd\AppData\Roaming\npm\yarn.CMD
      npm: 6.14.8 - D:\Downloads\nodejs\npm.CMD

补充信息

可能打包的时候将taro-ui组件有些代码漏掉了 (wx.webpackJsonp=wx.webpackJsonp||[]).push([[4],{"17":function(p,s,c){"use strict";c.r(s)}},[[17,0]]]); 只有这一行代码

F-react T-weapp V-2

Most helpful comment

@yinhunfeixue @qian-forver @PhantomRay @polichan @aYu-live
各位大佬,非常抱歉,这个问题排查了比较久,是个隐藏的比较深的问题,production 模式下 taro-ui 组件代码被当成副作用移除了, 可以加上 sideEffect 配置来解决

image

webpackChain (chain) {
  chain.optimization.sideEffects(false)
}

All 21 comments

7868 一样的问题。

等待 #7694

Taro CLI 2.2.7 environment info: System: OS: macOS 10.15.5 Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.2.0 - /usr/local/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.9.0 - /usr/local/bin/npm npmPackages: @tarojs/async-await: 2.2.7 => 2.2.7 @tarojs/components: 2.2.7 => 2.2.7 @tarojs/mini-runner: 2.2.7 => 2.2.7 @tarojs/plugin-babel: 2.2.7 => 2.2.7 @tarojs/plugin-csso: 2.2.7 => 2.2.7 @tarojs/plugin-sass: 2.2.7 => 2.2.7 @tarojs/router: 2.2.7 => 2.2.7 @tarojs/taro: 2.2.7 => 2.2.7 @tarojs/taro-alipay: 2.2.7 => 2.2.7 @tarojs/taro-h5: 2.2.7 => 2.2.7 @tarojs/taro-qq: 2.2.7 => 2.2.7 @tarojs/taro-quickapp: 2.2.7 => 2.2.7 @tarojs/taro-swan: 2.2.7 => 2.2.7 @tarojs/taro-tt: 2.2.7 => 2.2.7 @tarojs/taro-weapp: 2.2.7 => 2.2.7 @tarojs/webpack-runner: 2.2.7 => 2.2.7 eslint-config-taro: 2.2.7 => 2.2.7 eslint-plugin-taro: 2.2.7 => 2.2.7 nerv-devtools: ^1.5.7 => 1.5.7 nervjs: ^1.5.7 => 1.5.7 stylelint-config-taro-rn: 2.2.7 => 2.2.7 stylelint-taro-rn: 2.2.7 => 2.2.7 taro-ui: ^2.3.0 => 2.3.4

同样的问题,dev可以编译,build打包后的文件大多都如下所示,忘快点解决。
(my.webpackJsonp=my.webpackJsonp||[]).push([[47],{"285":function(p,s,c){"use strict";c.r(s)}},[[285,0]]]);

请问解决了吗?

现在只有2.1.6能正常build。以上版本全不能用。怎么这么严重的问题这么久都不能解决。再好的框架不能发布模式打包都无白费。

现在只有2.1.6能正常build。以上版本全不能用。怎么这么严重的问题这么久都不能解决。再好的框架不能发布模式打包都无白费。

请教,怎么能切换到2.1.6版本?

现在只有2.1.6能正常build。以上版本全不能用。怎么这么严重的问题这么久都不能解决。再好的框架不能发布模式打包都无白费。

请教,怎么能切换到2.1.6版本?

我是把taro 版本的cli放到package.json里。这样就不用担心全局taro cli版本的问题。

...
  "devDependencies": {
    "@tarojs/cli": "2.1.6",
    "@tarojs/mini-runner": "2.1.6",
    "@tarojs/webpack-runner": "2.1.6",
    "@types/react": "16.9.53",
    "@types/webpack-env": "1.15.3",
    "babel-eslint": "10.1.0",
    "babel-plugin-transform-class-properties": "6.24.1",
    "babel-plugin-transform-decorators-legacy": "1.3.5",
    "babel-plugin-transform-jsx-stylesheet": "1.0.0",
    "babel-plugin-transform-object-rest-spread": "6.26.0",
    "babel-plugin-transform-runtime": "6.23.0",
    "babel-preset-env": "1.7.0",
...

现在只有2.1.6能正常build。以上版本全不能用。怎么这么严重的问题这么久都不能解决。再好的框架不能发布模式打包都无白费。

请教,怎么能切换到2.1.6版本?

我是把taro 版本的cli放到package.json里。这样就不用担心全局taro cli版本的问题。

...
  "devDependencies": {
    "@tarojs/cli": "2.1.6",
    "@tarojs/mini-runner": "2.1.6",
    "@tarojs/webpack-runner": "2.1.6",
    "@types/react": "16.9.53",
    "@types/webpack-env": "1.15.3",
    "babel-eslint": "10.1.0",
    "babel-plugin-transform-class-properties": "6.24.1",
    "babel-plugin-transform-decorators-legacy": "1.3.5",
    "babel-plugin-transform-jsx-stylesheet": "1.0.0",
    "babel-plugin-transform-object-rest-spread": "6.26.0",
    "babel-plugin-transform-runtime": "6.23.0",
    "babel-preset-env": "1.7.0",
...

所有taro的依赖都切换到2.1.6吗?

现在只有2.1.6能正常build。以上版本全不能用。怎么这么严重的问题这么久都不能解决。再好的框架不能发布模式打包都无白费。

请教,怎么能切换到2.1.6版本?

我是把taro 版本的cli放到package.json里。这样就不用担心全局taro cli版本的问题。

...
  "devDependencies": {
    "@tarojs/cli": "2.1.6",
    "@tarojs/mini-runner": "2.1.6",
    "@tarojs/webpack-runner": "2.1.6",
    "@types/react": "16.9.53",
    "@types/webpack-env": "1.15.3",
    "babel-eslint": "10.1.0",
    "babel-plugin-transform-class-properties": "6.24.1",
    "babel-plugin-transform-decorators-legacy": "1.3.5",
    "babel-plugin-transform-jsx-stylesheet": "1.0.0",
    "babel-plugin-transform-object-rest-spread": "6.26.0",
    "babel-plugin-transform-runtime": "6.23.0",
    "babel-preset-env": "1.7.0",
...

所有taro的依赖都切换到2.1.6吗?

感谢,切换到2.1.6可以了

@yinhunfeixue @qian-forver @PhantomRay @polichan @aYu-live
各位大佬,非常抱歉,这个问题排查了比较久,是个隐藏的比较深的问题,production 模式下 taro-ui 组件代码被当成副作用移除了, 可以加上 sideEffect 配置来解决

image

webpackChain (chain) {
  chain.optimization.sideEffects(false)
}

我去验证一下

已验证,就是这个问题。困扰好久了,终于可以升级到taro最新版。

受这个影响的人超多,应该是不这么做就根本不能npm run build:weapp

非常感谢 @luckyadam

已验证,就是这个问题。困扰好久了,终于可以升级到taro最新版。

受这个影响的人超多,应该是不这么做就根本不能npm run build:weapp

非常感谢 @luckyadam

非常抱歉老铁,我们后续将努力保证版本问题,并更加积极修复问题

已验证,就是这个问题。困扰好久了,终于可以升级到taro最新版。
受这个影响的人超多,应该是不这么做就根本不能npm run build:weapp
非常感谢 @luckyadam

非常抱歉老铁,我们后续将努力保证版本问题,并更加积极修复问题

@luckyadam 加了webpack配置后,taro2.2以上版本build后正常了。但在plugin里使用taro-ui编译后,工具里依然会有报错,错误信息是【dist/miniprogram/plugin/pages/list/list.json: ["usingComponents"]["at-radio"]: "../../../npm/taro-ui/dist/weapp/components/radio/index" 未找到】,麻烦大佬验证并给下解决方案,谢谢了

@fenggang1024 也可能是开发者工具的问题,现在稳定版最新版基本问题复现这个问题,我这边升到开发版就没这个问题了。你可以在现在的开发者工具中打包一个开发版小程序 扫一下 如果手机端能正常运行 可以证明是开发者工具的问题 不是taro的问题。

好险,哈哈好奇发布前怎么测试的呢

目前使用2.2.8版本也出现了这个问题,请问2.x有修复了这个问题的更新的补丁升级吗,或者更新一下文档配置webpack也行,相似的问题开了太多找半天才找到。。

实测,有用!~

@yinhunfeixue @qian-forver @PhantomRay @polichan @aYu-live
各位大佬,非常抱歉,这个问题排查了比较久,是个隐藏的比较深的问题,production 模式下 taro-ui 组件代码被当成副作用移除了, 可以加上 sideEffect 配置来解决

image

webpackChain (chain) {
  chain.optimization.sideEffects(false)
}

@luckyadam Error: Component is not found in path "subpack/npm/taro-ui/dist/weapp/components/textarea/index" (using by "subpack/taroComponents/schemaForm/textarea/index")

taro 1.3.0-beta.4
taro-ui": "^1.5.4"
按照这个修改还是会报 taro 组件找不到

image

@yinhunfeixue @qian-forver @PhantomRay @polichan @aYu-live

各位大佬,非常抱歉,这个问题排查了比较久,是个隐藏的比较深的问题,production 模式下 taro-ui 组件代码被当成副作用移除了, 可以加上 sideEffect 配置来解决

image

```js

webpackChain (chain) {

chain.optimization.sideEffects(false)

}

```

@luckyadam Error: Component is not found in path "subpack/npm/taro-ui/dist/weapp/components/textarea/index" (using by "subpack/taroComponents/schemaForm/textarea/index")

taro 1.3.0-beta.4

taro-ui": "^1.5.4"

按照这个修改还是会报 taro 组件找不到

image

你这个版本太旧了,还是beta。估计很难得到support。

@yinhunfeixue @qian-forver @PhantomRay @polichan @aYu-live

各位大佬,非常抱歉,这个问题排查了比较久,是个隐藏的比较深的问题,production 模式下 taro-ui 组件代码被当成副作用移除了, 可以加上 sideEffect 配置来解决

image

webpackChain (chain) {

chain.optimization.sideEffects(false)

}

@luckyadam Error: Component is not found in path "subpack/npm/taro-ui/dist/weapp/components/textarea/index" (using by "subpack/taroComponents/schemaForm/textarea/index")
taro 1.3.0-beta.4
taro-ui": "^1.5.4"
按照这个修改还是会报 taro 组件找不到
image

你这个版本太旧了,还是beta。估计很难得到support。

公司是做平台的,有不同功能类型的小程序,升级 taro 版本成本太大了,因为有很多功能点和小程序类型需要测试,整个流程下来成本太大了,需要大佬帮助下 @luckyadam @PhantomRay

https://github.com/NervJS/taro/issues/8010
麻烦问下公告中提到的修改地方是这个文件下修改吗? @luckyadam @PhantomRay
image

Was this page helpful?
0 / 5 - 0 ratings