-
-
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
How to obtain production environment react.lazy Our support #2130
Comments
I think in build mode, any module path must be determined constant string. |
Try to add a file extension to your import statement, e.g. import(`../pages/${page}.js`) Vite is using rollup for its build, so I assume the same limitations apply when it comes to dynamic imports: |
Is it because of the difference between the mechanism of Web pack and that of CRA Adding a file extension will still report an error at runtime( use
So the conclusion is that vite doesn't support it for the time being, right? |
In that case
No, it is supported, what you encounter is a bug (either with your code or Vite). But unless you provide a repro I don't think it'll get worked on and fixed. |
@jonaskuske Thank you very much.👍
I've looked at the restrictions again, and now I understand Two main points
Since my And Okay, I feel like I'm stupid. I'll close this issue later🤦♂️ |
Awesome, glad I could help! 🤞 |
Is your feature request related to a problem? Please describe.
react.lazy It's available during development, like this
But after build, the import failed
Describe the solution you'd like
After build, it can work normally
Describe alternatives you've considered
Additional context
I just tried to use vite in react to see if I could migrate from CRA 😌
The text was updated successfully, but these errors were encountered: