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.js 和 verdors.js 循环引用 #16424

Open
fisker opened this issue Aug 30, 2024 · 3 comments
Open

编译后的代码 taro.js 和 verdors.js 循环引用 #16424

fisker opened this issue Aug 30, 2024 · 3 comments
Labels
F-vue3 Framework - Vue 3 T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@fisker
Copy link

fisker commented Aug 30, 2024

相关平台

微信小程序

小程序基础库: 3.5.2
使用框架: Vue 3

复现步骤

使用 vite vue3 时 编译的产物 taro.js 可能需要 babel 的代码 比如 @babel/helpers/lib/helpers/typeof.js, 现在的分包策略会导致其被打包进 vendors.js 从而导致循环引用

本地测试,

if (testByReg2DExpList([taroDeps, vueRelatedDeps, tslibDeps, commonjsHelpersDeps])(id)) return 'taro'

加上 /@babel\//.test(id) 打包到 taro.js 可以解决。

期望结果

正常工作

实际结果

An error thrown with a message like

taro.defineComponent is not a function

环境信息

Taro v4.0.4


  Taro CLI 4.0.4 environment info:
    System:
      OS: Windows 10 10.0.19044
    Binaries:
      Node: 20.15.0
      Yarn: 1.22.22
      npm: 10.7.0
    npmPackages:
     <ommited, I'm not current on that branch>
@taro-bot2 taro-bot2 bot added F-vue3 Framework - Vue 3 T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Aug 30, 2024
This was referenced Aug 31, 2024
@ZEJIA-LIU
Copy link
Contributor

感谢反馈,可以使用自定义的vite插件或者taro的hooks ModifyViteConfig 来尝试修改这块chunks 的拆分,Taro 后续会针对这个问题进行更好的优化~

@baoshuaiZealot
Copy link

我也是这个问题, 而且我是taro-cli4.0.4 init后使用taro-ui模板 直接就不能启动. 搞笑

@baoshuaiZealot
Copy link

你是怎么解决的? 如果有了解决办法希望告知我一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-vue3 Framework - Vue 3 T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
Status: Todo
Development

No branches or pull requests

3 participants