vite
vite copied to clipboard
热更新失败,import.meta.glob会引起circular imports detected
Describe the bug
我有一个路由组件user.vue,他引入了一个公共组件CommonList.vue;
在CommonList.vue中引入了user.js(pinia store模块);
在user.js中我写了动态生成路由的方法,其中使用了
import.meta.glob来导入所有路由组件(包括 user.vue)进行动态加载。
但是这种导入让我每次修改user.vue,会提示circular imports detected,并给出了循环导入的顺序
Reproduction
https://stackblitz.com/edit/vitejs-vite-4sktev?file=vite-project%2Fsrc%2FApp.vue,vite-project%2Fsrc%2Ftest.js,vite-project%2Fsrc%2Fcomponents%2FHelloWorld.vue&terminal=dev
Steps to reproduce
cd vite-project npm i npm run dev 修改HelloWorld.vue会触发circular imports detected
System Info
System:
OS: Linux 5.0 undefined
CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 18.18.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 9.4.2 - /usr/local/bin/npm
pnpm: 8.10.5 - /usr/local/bin/pnpm
Used Package Manager
npm
Logs
No response
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [X] The provided reproduction is a minimal reproducible example of the bug.
This should be fixed in https://github.com/vitejs/vite/pull/15118