fix(nuxt3): don't rely on auto-imports for defineAsyncComponent (#4454)

This commit is contained in:
Daniel Roe 2022-04-20 11:20:49 +01:00 committed by GitHub
parent 24923db992
commit d469c9a6d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,8 +52,8 @@ function transform (code: string, id: string, components: Component[], mode: Loa
imports.add(genImport('#app/components/client-only', [{ name: 'createClientOnly' }]))
}
if (lazy) {
// Nuxt will auto-import `defineAsyncComponent` for us
imports.add(`const ${identifier}_lazy = defineAsyncComponent(${genDynamicImport(component.filePath)})`)
imports.add(genImport('vue', [{ name: 'defineAsyncComponent', as: '__defineAsyncComponent' }]))
imports.add(`const ${identifier}_lazy = __defineAsyncComponent(${genDynamicImport(component.filePath)})`)
return isClientOnly ? `createClientOnly(${identifier}_lazy)` : `${identifier}_lazy`
} else {
imports.add(genImport(component.filePath, [{ name: component.export, as: identifier }]))