Top level await with SWC #64641
Replies: 7 comments
-
This is an incredibly important language feature and IMO it has been a mistake to deprioritize it in general and leave it as an experimental opt-in. Top-level await is one of the only hangups that prevent valid JS programs from being executed inside Next, the others being:
This is currently causing issues trying to import perfectly valid modules that contain top-level await statements, even with the flag enabled (as you mentioned, it's not well-tested). |
Beta Was this translation helpful? Give feedback.
-
Yeah I am new to developing with next.js and running into this issue as well. I'm new to In my
|
Beta Was this translation helpful? Give feedback.
-
Is there any workaround for using top level await with swc until the feature is supported? |
Beta Was this translation helpful? Give feedback.
-
This seems to prevent Apollo Server setup or at least to make it harder, the open PR to update to Apollo 3 also use a top level await: #30082 |
Beta Was this translation helpful? Give feedback.
-
I just ran into this issue and worked around it by using babel instead. Just create a |
Beta Was this translation helpful? Give feedback.
-
There is a |
Beta Was this translation helpful? Give feedback.
-
Converted to a discussion as per our Triaging policy. This does not mean that the discussion got closed, feel free to discuss further! |
Beta Was this translation helpful? Give feedback.
-
Before the launch of SWC by default we opted out the test for top level await as it is still quite experimental. We have to revisit top level await support, e.g. check how it's handled with Babel currently, to make sure it works with SWC.
Beta Was this translation helpful? Give feedback.
All reactions