-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
preload 动态组件 异常处理 #3698
Comments
Please rework the issue description and add a reproduction link, otherwise this issue will be just closed soon |
vite/packages/vite/src/node/plugins/importAnalysisBuild.ts line 27 |
Okay it seems you have hard problems to communicate in english auto translated: |
~~! 问题是 模拟断网情况下 再次加载 貌似不加载了 。。。 使用谷歌浏览器 offline 点击一次 在恢复网络。 使用情景是 vue-router component: () => import( |
或者是我在 vue-router捕获异常 然后 重启vue-router? |
|
路由 =》 动态组件 =》 断网 => seen[dep] = true =>网络恢复 =》 认为有缓存 =》不在加载动态组件 |
但是这个代码跟加载动态组件一点关系都没有啊? |
还请再仔细看看这里的代码。 而异步组件断网后加载失败是因为 import() 这个 promise 被 reject 了,一个 promise 不能被 reject 两次,所以恢复网络后它也不会再执行。 |
OK,我再仔细看了一遍代码,收回「无关紧要」的说法。 |
是因为css 加载失败 导致 后面的路由 搞不动了么? 大神 靠你了 |
这里有两个问题:
第二个问题可能需要和这个 issue 一同解决 #3469 我们这周周会上会讨论一下。 |
This issue has been locked since it has been closed for more than 14 days. If you have found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Vite version. If you have any other comments you should join the chat at Vite Land or create a new discussion. |
Describe the bug
return Promise.all( deps.map((dep) => { // @ts-ignore if (dep in seen) return // @ts-ignore seen[dep] = true const isCss = dep.endsWith('.css') const cssSelector = isCss ? '[rel="stylesheet"]' : '' // @ts-ignore check if the file is already preloaded by SSR markup if (document.querySelector(`link[href="${dep}"]${cssSelector}`)) { return } // @ts-ignore const link = document.createElement('link') // @ts-ignore link.rel = isCss ? 'stylesheet' : scriptRel if (!isCss) { link.as = 'script' link.crossOrigin = '' } link.href = dep // @ts-ignore document.head.appendChild(link) if (isCss) { return new Promise((res, rej) => { link.addEventListener('load', res) link.addEventListener('error', rej) }) } }) ).then(() => baseModule())异常处理 seen[dep] = true 至少放在后面
Reproduction
System Info
Output of
npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers
:Used package manager:
Logs
Before submitting the issue, please make sure you do the following
The text was updated successfully, but these errors were encountered: