-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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 loading routes don't work in generated build #339
Comments
This currently seems to be a limitation of esbuild. |
I see, but this is such an important case it will be good to have some kind of workaround. Technically routes are known, so build tool can process them and add tree shakable dynamically loaded chunks. |
Full dynamic import path imports are currently untouched during build, because Rollup doesn't provide default handling for it. |
@yyx990803 Is there any alternative syntax to use, until esbuild starts to support this? |
@husayt In 0.20.3 vite use rollup-plugin-dynamic-import-variables, so it should works. |
Actually indeed it does work now. Thanks @yyx990803 |
Describe the bug
Routes stop working in generated bundle when I use dynamically imported (async) route components (in dev all works fine):
Reproduction
Reproduction Repo: https://github.com/husayt/vite-tailwind-starter
Reproduction step
When i go to localhost:8080 I get this error in the console:
Same with
/about
. So routes don't work, although they work fine withyarn dev
System Info
vite
version: 0.20.2Detailed description
Routes work fine in the original project from this repo where pages imported statically.
But once I change routes to dynamic import, they stop working in generated bundle (dev still works fine)
The text was updated successfully, but these errors were encountered: