From d469c9a6d7a08b951783f393223c45714dfcba66 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 20 Apr 2022 11:20:49 +0100 Subject: [PATCH] fix(nuxt3): don't rely on auto-imports for `defineAsyncComponent` (#4454) --- packages/nuxt/src/components/loader.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/components/loader.ts b/packages/nuxt/src/components/loader.ts index b90f082ce0..b490a0d214 100644 --- a/packages/nuxt/src/components/loader.ts +++ b/packages/nuxt/src/components/loader.ts @@ -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 }]))