This repository was archived by the owner on Dec 25, 2024. It is now read-only.
This repository was archived by the owner on Dec 25, 2024. It is now read-only.
Support async component registration #43
Closed
Description
This does not work:
<script setup lang="ts">
const HelloWorld = () => import('./HelloWorld.vue')
</script>
unplugin-vue2-script-setup
does not hoist async import up and you get runtime error Uncaught ReferenceError: HelloWorld is not defined
.
Possible solutions:
- Ignore it 🙂
Pros: don't need to implement it
Cons: need to use separate script - Hoist async component imports
Pros: easy to implement - just hoistconst Component = () => import()
Cons: different API from Vue 3 - Add global
defineAsyncComponent
macro
Pros: API similar to Vue 3
Cons: When the app is migrated to Vue 3 will need to add missing imports. (Could be a pro withunplugin-auto-import
) - Add virtual package (
script-setup
for example) that exportsdefineAsyncComponent
Pros: API similar to Vue 3, easy search and replace imports when the app is migrated to Vue 3
Cons: Need to add virtual package
@antfu, what solution do you prefer? I'm not sure if 3 or 4 is better.
https://github.com/Demivan/unplugin-vue2-script-setup here I created basic implementation of solution 4.
Metadata
Metadata
Assignees
Labels
No labels