taro ui组件库和自定小程序sentry的npm包冲突

am46iovg  于 2022-10-27  发布在  其他
关注(0)|答案(8)|浏览(263)

相关平台

微信小程序

小程序基础库: 最新几个版本就行
使用框架: React

复现步骤

引入自定义组件库(taro-ui也可以),然后再引入npm包sentry-miniapp

期望结果

期望ui库可以和npm包同时使用

实际结果

引入sentry-miniapp后,组件库报错

SystemError (jsEnginScriptError)
Component is not found in path "npm/@h/mp-devkit/lib/weapp/widgets/LoginWidget/LoginWidget" (using by "pages/Index/Index")
Error: Component is not found in path "npm/@h/mp-devkit/lib/weapp/widgets/LoginWidget/LoginWidget" (using by "pages/Index/Index")

环境信息

👽 Taro v2.2.10

  Taro CLI 2.2.10 environment info:
    System:
      OS: macOS 10.15.7
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 12.18.4 - /var/folders/fd/x6874tgx0hscfdvww7tcprq80000gq/T/yarn--1605154035000-0.0968001380622785/node
      Yarn: 1.22.5 - /var/folders/fd/x6874tgx0hscfdvww7tcprq80000gq/T/yarn--1605154035000-0.0968001380622785/yarn
      npm: 6.14.8 - ~/.npm-global/bin/npm
    npmPackages:
      @tarojs/cli: ^2.2.10 => 2.2.10 
      @tarojs/components: ^2.2.10 => 2.2.10 
      @tarojs/mini-runner: ^2.2.10 => 2.2.10 
      @tarojs/mobx: ^2.2.10 => 2.2.10 
      @tarojs/mobx-common: ^2.2.10 => 2.2.10 
      @tarojs/mobx-h5: ^2.2.10 => 2.2.10 
      @tarojs/plugin-sass: ^2.2.10 => 2.2.10 
      @tarojs/plugin-terser: ^2.2.10 => 2.2.10 
      @tarojs/router: ^2.2.10 => 2.2.10 
      @tarojs/taro: ^2.2.10 => 2.2.10 
      @tarojs/taro-h5: ^2.2.10 => 2.2.10 
      @tarojs/taro-weapp: ^2.2.10 => 2.2.10 
      @tarojs/webpack-runner: ^2.2.10 => 2.2.10 
      eslint-config-taro: ^3.0.2 => 3.0.2 
      eslint-plugin-taro: ^3.0.16 => 3.0.16 
      nerv-devtools: ^1.5.7 => 1.5.7 
      nervjs: ^1.5.7 => 1.5.7 
    npmGlobalPackages:
      typescript: 3.9.7

补充信息

使用自定义组件库是可以的,但是引入npm包后就会报错: 找不到组件库的组件

a0zr77ik

a0zr77ik3#

自定义组件库详细信息:

👽 Taro v2.2.9

  Taro CLI 2.2.9 environment info:
    System:
      OS: macOS 10.15.7
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 12.18.4 - /var/folders/fd/x6874tgx0hscfdvww7tcprq80000gq/T/yarn--1605176234370-0.3976237305629893/node
      Yarn: 1.22.5 - /var/folders/fd/x6874tgx0hscfdvww7tcprq80000gq/T/yarn--1605176234370-0.3976237305629893/yarn
      npm: 6.14.8 - ~/.npm-global/bin/npm
    npmPackages:
      @tarojs/cli: ^2.2.9 => 2.2.9 
      @tarojs/components: ^2.2.9 => 2.2.9 
      @tarojs/mini-runner: ^2.2.9 => 2.2.9 
      @tarojs/mobx: ^2.2.9 => 2.2.9 
      @tarojs/mobx-h5: ^2.2.9 => 2.2.9 
      @tarojs/plugin-sass: ^2.2.9 => 2.2.9 
      @tarojs/router: ^2.2.9 => 2.2.9 
      @tarojs/taro: ^2.2.9 => 2.2.9 
      @tarojs/taro-h5: ^2.2.9 => 2.2.9 
      @tarojs/taro-weapp: ^2.2.9 => 2.2.9 
      @tarojs/webpack-runner: ^2.2.9 => 2.2.9 
      eslint-config-taro: ^2.2.9 => 2.2.9 
      eslint-plugin-taro: ^2.2.9 => 2.2.9 
      nerv-devtools: ^1.5.7 => 1.5.7 
      nervjs: ^1.5.7 => 1.5.7 
    npmGlobalPackages:
      typescript: 3.9.7

✨  Done in 8.78s.
z9smfwbn

z9smfwbn4#

做了一个小测试:

版本sentrytaro-ui(next)Sentry+uisentry + custom-ui
T3✓(ui-next)✓(ui-next)×(ui用的taro 2.2.9)
T2✓(ui)✓(ui)×(ui用的taro 2.2.9)

目测是自定义组件库的taro版本引起的,小弟再排查一下

fnx2tebb

fnx2tebb5#

经过一番测试发现:【自定义的组件库】和【其他ts类型的npm包】同时引入会出现问题

zzzyeukh

zzzyeukh6#

【自定义组件库2.2.9】可以单独使用,【其他类型ts的npm包(例如sentry-miniapp)】也能单独使用。

wgx48brx

wgx48brx7#

目前问题已定位到: A包的某个函数(AF)中使用的B包的某个函数(BF)会抛出上面的错

// packageA
export const AF = (ap) => `${ap}aaa`
// packageB
const b = 0
export const BF = (bp) => bp(b)
import {AF } from 'A'
import { BF } from 'B'

somepackge.use(BF(AF)) // B包的BF里用了A包的AF就会抛出上面的错

// somepackge.use(BF(e=> e)) // 自定义是可以的
rqmkfv5c

rqmkfv5c8#

问题定位在:

  • 自己的taro的ui库(packageA)

  • js工具函数(AF)

  • ui

  • 自定义的其他库 (packageB)

  • 自定义的小程序sentry库(BF)

BF中传入了AF工具,触发了报错

somepackge.use(BF(AF))

相关问题