fix(nuxt): add missing import in islands template (#19870)

This commit is contained in:
Harlan Wilton 2023-03-23 11:19:26 +11:00 committed by GitHub
parent 8b06b06a07
commit c6f928d786
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -92,13 +92,13 @@ export const componentsIslandsTemplate: NuxtTemplate<ComponentsTemplateContext>
// .server components without a corresponding .client component will need to be rendered as an island
(component.mode === 'server' && !components.some(c => c.pascalName === component.pascalName && c.mode === 'client'))
)
return islands.map(
return ['import { defineAsyncComponent } from \'vue\'', ...islands.map(
(c) => {
const exp = c.export === 'default' ? 'c.default || c' : `c['${c.export}']`
const comment = createImportMagicComments(c)
return `export const ${c.pascalName} = /* #__PURE__ */ defineAsyncComponent(${genDynamicImport(c.filePath, { comment })}.then(c => ${exp}))`
}
).join('\n')
)].join('\n')
}
}