Skip to content
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

feat: make top-level await vue islands possible #178

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

maoberlehner
Copy link
Contributor

Description 📖

Vue components using top level await in <script setup> compile to
async setup() {} components which need <Suspense> to render.

Background 📜

This was happening because

The Fix 🔨

By conditionally wrapping islands in <Suspense> we make it possible to use async setup hooks in island components.

Vue components using top level await in `<script setup>` compile to
`async setup() {}` components which need `<Suspense>` to render.

See: https://vuejs.org/api/sfc-script-setup.html#top-level-await
@nx-cloud
Copy link

nx-cloud bot commented Aug 7, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 4d5a000. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 3 targets

Sent with 💌 from NxCloud.

@ElMassimo
Copy link
Owner

I like the idea of supporting async setup in islands out of the box. You can already achieve the same by wrapping manually, but this is more ergonomic.

Is Suspense tree-shakable in recent Vue builds?

If it is, it would be nice to do the wrapping at the island level, to allow tree-shaking Suspense when it's not used

If it's not, then we could simplify and always wrap the app in Suspense.

@maoberlehner
Copy link
Contributor Author

maoberlehner commented Aug 14, 2022

I think it should be tree-shakable. But I don't know how I can implement wrapping at the island level.

@ElMassimo ElMassimo added the enhancement New feature or request label Aug 28, 2022
@phonzammi
Copy link

Is Suspense tree-shakable in recent Vue builds?

Yes it is, vuejs on twitter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants