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
lazy imported modules are not bundled correctly on building #4840
Comments
I finished up by patch vite for now. diff --git a/node_modules/vite/dist/node/chunks/dep-1be34a63.js b/node_modules/vite/dist/node/chunks/dep-1be34a63.js
index e0418aa..64f4a95 100644
--- a/node_modules/vite/dist/node/chunks/dep-1be34a63.js
+++ b/node_modules/vite/dist/node/chunks/dep-1be34a63.js
@@ -34720,7 +34720,7 @@ function preload(baseModule, deps) {
}
return Promise.all(deps.map((dep) => {
// @ts-ignore
- dep = `${base}${dep}`;
+ dep = /^(https?:\/)?\//.test(dep) ? dep : `${base}${dep}`;
// @ts-ignore
if (dep in seen)
return; But it still does not work in my reproduction, that seems two different problems. |
@hex-ci Is the reproduction related too? It seems two different issues, because in the reproduction, there is no prism chunks generated at all. |
Vite 2.5.7 version has been released, you can try to see if this version solves your problem. |
@hex-ci Hi, I tried my local project, it seems working now. However, it is still broken on the reproduction, as I said before, it seems a different issue. |
Vite 2.5.7 fixes the problem of .css dynamic import failure caused by incorrect |
I took a look, the path of |
@hex-ci Hmmm, but it works on development? |
I tried the development environment, and I found that |
As for why writing an extra |
I think that after modifying the path, the development environment is OK. Vite 2.5.7 solves your problem. |
Without modifying or upgrading to 2.5.7, it is still working on development when using 2.5.6. |
I think it's the root cause, so vite should warn about incorrect |
Maybe Vite needs to warn that your path exceeds the project root directory. |
Your problem is actually caused by two aspects. One is a bug in Vite, and the other is that your path is written incorrectly. After both of these problems are fixed, your project will be normal. |
#4740 was released in 2.5.7 so it sounds like this is fixed https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md#257-2021-09-13 I'll close this as a result. Please file a new issue requesting a warning when an extra |
Describe the bug
The following pattern runs very well on development:
But it seems not been bundled at all on building, confirmed with
build.rollupOptions.manualChunks
Reproduction
https://github.com/JounQin/test/tree/repro/vite_public_path
yarn dev
works fineyarn build && yarn serve
does not workAnd there is no
prism
related chunk indist/assets
In my true app (it's a bit huge for a reproduction), they are bundled as
prism.*.js
chunks correctly, but the public path seems brokenSystem Info
Used Package Manager
yarn
Logs
Validations
The text was updated successfully, but these errors were encountered: