-
-
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
Top level await for import() function stopped working in Chrome #18156
Comments
Start a new pull request in StackBlitz Codeflow. |
From your system info, I think you're hitting a chrome bug: |
I reproduced it in a fresh Vite (Vanilla) project. I also tested |
Can confirm, a relatively simple app created with @vitejs/plugin-react-swc is now behaving this way, producing a blank page, in Chrome/Edge 129. Running the same app in Opera 113 works fine. There's no use of Anything that can be done other than using another browser and waiting for an update to Chrome/Edge? |
try |
This seems to be related to a Chromium bug. It's fixed in Chrome 130 available via the Canary nightly build or Microsoft Edge Canary and Dev Channel Builds. |
I am using vite-plugin-top-level-await plugin as a temporary workaround. |
It eventually did work but we loaded the plugin to late and in the wrong place. We are using Quasar with boot files and we had to add it to the vitePlugins in the quasar config to make this work. |
Problem seems to be gone for me in Edge 130. |
Closing as this seems to be fixed in chromium 130 and chrome/edge 130 has been released. |
Describe the bug
For some reason when building for production and using top level await for an import() function that imports a module which imports another module the import() never completes with await. This started happening recently on Chrome (on Safari and Firefox it works fine) and this does not happen when running in dev mode. Not really sure if the issue is Chrome related or with vite bundle when running for production.
Here is a quick summary of the reproduce link:
We have a
main.ts
file with a top level await import formodule1.ts
module1.ts
includes an export of function that imports another module. In this casemodule2.ts
Now running this with stackblitz in dev mode
npm run dev
you should see "Finished" displayed on both Chrome and Safari.Running
npm build-prod
and thennpm run preview
displays "Finished" in Safari, but in Chromeawait import('./module1')
never completes and you should see "Loading..."Workaround is to use
import('./module1').then(() => // code to be executed after module load)
instead ofawait import('./module1');
Reproduction
https://stackblitz.com/edit/vitejs-vite-85uvzu?file=src%2Fmain.ts
Steps to reproduce
npm run build-prod
npm run preview
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: