diff --git a/packages/nuxt/src/components/loader.ts b/packages/nuxt/src/components/loader.ts index 8c74efd0e1..00f3139aa7 100644 --- a/packages/nuxt/src/components/loader.ts +++ b/packages/nuxt/src/components/loader.ts @@ -73,12 +73,11 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => { if (lazy) { // Temporary hardcoded check to verify runtime functionality - if (name === "DelayedWrapperTestComponent") { - imports.add(genImport(clientDelayedComponentRuntime, [{ name: 'createLazyIOClientPage' }])) - imports.add(`const ${identifier} = createLazyIOClientPage(${JSON.stringify(name)})`) - identifier += '_delayedIO' - } - else { + if (name === 'DelayedWrapperTestComponent') { + imports.add(genImport(clientDelayedComponentRuntime, [{ name: 'createLazyIOClientPage' }])) + imports.add(`const ${identifier} = createLazyIOClientPage(${JSON.stringify(name)})`) + identifier += '_delayedIO' + } else { imports.add(genImport('vue', [{ name: 'defineAsyncComponent', as: '__defineAsyncComponent' }])) identifier += '_lazy' imports.add(`const ${identifier} = __defineAsyncComponent(${genDynamicImport(component.filePath, { interopDefault: false })}.then(c => c.${component.export ?? 'default'} || c)${isClientOnly ? '.then(c => createClientOnly(c))' : ''})`)