更改 vue-router 的导入写法,以便适应 vue-router 在未来 v5 版本内,更改文件导出格式所带来的破坏性变更#5824
更改 vue-router 的导入写法,以便适应 vue-router 在未来 v5 版本内,更改文件导出格式所带来的破坏性变更#5824ruan-cat wants to merge 3 commits intodcloudio:nextfrom
Conversation
|
@chouchouji 你好,请审阅pr。 |
|
应该是引入
我不是很确定 vuejs/router#2572 说的内容是否对uniapp有潜在的影响,需要进行测试web和app端表现是否正常 |
|
@chouchouji 你说的对。已作出更改,现在改成导入 |
不要版本判断,修改为 |
…router.esm-bundler.js
|
还需要做一下验证,uniapp和uniappx的web端和uniapp的app端项目能不能正常运行 |
至少可以肯定, 稍后我新建一个全新的 uniapp vite-ts 项目,测试 web 端和 app 端场景下是否正常可用。 |
|
@chouchouji 自测结果如下,web端和app端均通过测试。
|
|
最好是测试一些大型项目,vue router主要是路由相关的,比如 hello-uniapp 和 hello-uniapp-x 这两个大型项目。还有要看看 uni-app-x 上是否正常 |
There was a problem hiding this comment.
Pull Request Overview
This PR updates the vue-router import path to prepare for breaking changes in the upcoming v5 release, where the dist/vue-router.esm-bundler.js file will be removed. The change from dist/vue-router.esm-bundler.js to dist/vue-router.mjs ensures compatibility with both current versions (4.6.3+) and future v5 releases, while also fixing build failures that occur specifically in vue-router v4.6.0.
- Updated vue-router module resolution path to use the new
.mjsexport format - Follows the established pattern from the pinia v3 migration
- Prevents build failures in uniapp H5 projects when using affected vue-router versions
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.







问题背景:为什么要更改?
vue-router 明确在未来的 v5 版本内不会提供
dist/vue-router.esm-bundler.js导出文件vue-router.esm-bundler.jsnot exported invue-router@4.6.0version vuejs/router#2569 (comment)为什么选择在 vue-router v5 版本还没有发版的时候就提前适配?
在特定的
vue-router@4.6.0版本内,就会出现构建故障。不更改会带来什么问题?
uniapp H5 项目在
vue-router@4.6.0版本下是失败的4.6.0分支: https://github.com/ruan-cat/bug-in-vue-router-4.6.0-with-uniapp/tree/4.6.0如下图所示,在依赖关系指定为
vue-router@4.6.0时,是失败的。uniapp H5 项目在
vue-router@4.5.1版本下是成功的4.5.1分支: https://stackblitz.com/~/github.com/ruan-cat/bug-in-vue-router-4.6.0-with-uniapp?file=package.json如下图所示,在依赖关系指定为
vue-router@4.5.1时,是成功的。uniapp H5 项目在
vue-router@4.6.3版本下是成功的4.6.3分支: https://github.com/ruan-cat/bug-in-vue-router-4.6.0-with-uniapp/tree/4.6.3如下图所示,在依赖关系指定为
vue-router@4.6.3时,是成功的。有什么故障先例?
fix(vite-plugin-uni): 修复 pinia v3 版本 访问 dist 报错的bug模仿 pinia v3 版本的更改先例,提前更改 vue-router v5 版本的导入写法
预期被修改的文件