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

支持 @vueuse/core@10 #4604

Closed
ModyQyW opened this issue Nov 23, 2023 · 8 comments
Closed

支持 @vueuse/core@10 #4604

ModyQyW opened this issue Nov 23, 2023 · 8 comments
Assignees
Labels
completed 已完成 enhancement New feature or request 评论中有最佳答案 replay best

Comments

@ModyQyW
Copy link

ModyQyW commented Nov 23, 2023

新功能描述

支持 @vueuse/core@10

现状及问题

目前,uni-app 所使用的 vue 文件没有导出 TransitionGroup,导致 @vueuse/core@10 无法正常使用。一旦从 @vueuse/core@10 导入,就会报错。

image

尝试方案

可参考 vue-demi 的做法,增加导出。

image

https://github.com/vueuse/vue-demi/blob/main/lib/v2/index.mjs

补充信息

/

@ModyQyW ModyQyW added the enhancement New feature or request label Nov 23, 2023
@Otto-J
Copy link
Member

Otto-J commented Nov 23, 2023

欢迎 PR,这是最近 v10 版本的限制,还是低版本也有相同的限制?

@Otto-J Otto-J self-assigned this Nov 23, 2023
@ModyQyW
Copy link
Author

ModyQyW commented Nov 24, 2023

这是最近 v10 版本的限制,还是低版本也有相同的限制?

是 v10 开始有的限制。

欢迎 PR

我初步看了一下,目前 vue 会被 alias 成 @dcloudio/uni-mp-vue/dist/vue.runtime.esm.js,我认为可以直接在 dev 分支 packages/uni-mp-vue/dist/vue.runtime.esm.js 文件内补充导出处理该问题。但我不太确定这个文件是否通过某种方式自动生成,如果是,直接修改文件不太妥当。请问可以告知我怎么做会更合适吗?谢谢! @Otto-J

@Otto-J
Copy link
Member

Otto-J commented Nov 24, 2023

很高兴看到你的跟进,已经比较深入了,uni 有你可以做得更好。

我沟通了下,目前有一些比较 hack 的地方。目前看到的 uni-mp-vue 这块在 npm 上可以看 https://www.npmjs.com/package/@dcloudio/uni-mp-vue?activeTab=versions 版本发布情况,这部分源码在 https://github.com/fxy060608/vue-next 仓库下,这部分信息我先整理下,希望可以让这部分更加公开透明。

这部分的调整我也反馈给上游,现看下反馈再继续看这个问题。

@ModyQyW
Copy link
Author

ModyQyW commented Nov 24, 2023

这部分的调整我也反馈给上游,现看下反馈再继续看这个问题。

期待反馈,感谢 🙏

@SoulLyoko
Copy link

可以临时写个vite插件给vueuse加个polyfill来解决:

// uni-polyfill.ts
import type { Plugin } from 'vite'

export function uniPolyfill(): Plugin {
  return {
    name: 'vite-plugin-uni-polyfill',
    transform(code, id) {
      if (!id.endsWith('@dcloudio/uni-mp-vue/dist/vue.runtime.esm.js'))
        return
      code += `
// polyfill for @vueuse/core
export const render = () => {}
export const TransitionGroup = {}
`
      return code
    },
  }
}
// vite.config.ts
import { uniPolyfill } from './plugins/uni-polyfill'

export default {
  plugins: [
    // ...
    uniPolyfill()
  ]
}

@ModyQyW
Copy link
Author

ModyQyW commented Dec 8, 2023

有需要也可以参照我这篇文改一下 https://juejin.cn/post/7308899425149042739

@Otto-J
Copy link
Member

Otto-J commented Jan 9, 2024

最近升级了一些底层依赖,经过测试,h5 已支持 vueuse/core@10 的 createGlobalState

同样的思路,如果后续升级遇到相关以来找不到,未导出的情况,可以按照楼上两位的思路进行修改

@Otto-J
Copy link
Member

Otto-J commented Jan 9, 2024

如果有更广泛的测试需求,我可以开一个专门的讨论帖进行讨论。

@Otto-J Otto-J closed this as completed Jan 9, 2024
@Otto-J Otto-J added completed 已完成 评论中有最佳答案 replay best labels Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed 已完成 enhancement New feature or request 评论中有最佳答案 replay best
Projects
None yet
Development

No branches or pull requests

3 participants