-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Closed as not planned
Closed as not planned
Copy link
Description
Vue version
v3.3.11
Link to minimal reproduction
Steps to reproduce
- Create a JavaScript module which uses top-level await, e.g., calls
fetch
to load some data. - Export that data from the JavaScript module.
- Import that module inside
script setup
of your Vue component. - Use that component without wrapping it with
Suspense
.
What is expected?
Multiple options:
- That data would not be loaded.
- That component would be rendered before data is loaded.
- That Vue complains that the component is not wrapped inside
Suspense
and that the component is async.
What is actually happening?
It just works. No need for Suspense
, no need to make component async. Data is nicely loaded.
System Info
No response
Any additional comments?
So I discovered this because I was using this pattern to load some data. And then I wanted to also use top-level await inside script setup
. But it didn't work. So I was surprised why the simple await does not work, while import does. I realized that there is something strange going on. In my view:
- Or
script setup
should allow top-level await withoutSuspense
. - Or top-level await in imported modules should not work either.
Personally, I would vote for script setup
to support top-level await without Suspense
. While I understand why some people like UX of Suspense
, to me it makes little sense because I already handle lazy loading of components (and data) through Vue router hooks.
Metadata
Metadata
Assignees
Labels
No labels