fix(nuxt3): destructure components options (#1165)

This commit is contained in:
Daniel Roe 2021-10-18 12:59:31 +01:00 committed by GitHub
parent adf497046b
commit 117b3aa524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,7 +25,7 @@ const createImportMagicComments = (options: ImportMagicCommentsOptions) => {
export const componentsTemplate = { export const componentsTemplate = {
filename: 'components.mjs', filename: 'components.mjs',
getContents (options: ComponentsTemplateOptions) { getContents ({ options }: { options: ComponentsTemplateOptions }) {
return `import { defineAsyncComponent } from 'vue' return `import { defineAsyncComponent } from 'vue'
const components = { const components = {
@ -50,7 +50,7 @@ export default function (nuxt) {
export const componentsTypeTemplate = { export const componentsTypeTemplate = {
filename: 'components.d.ts', filename: 'components.d.ts',
write: true, write: true,
getContents: (options: ComponentsTemplateOptions) => `// Generated by components discovery getContents: ({ options }: { options: ComponentsTemplateOptions }) => `// Generated by components discovery
declare module 'vue' { declare module 'vue' {
export interface GlobalComponents { export interface GlobalComponents {
${options.components.map(c => ` '${c.pascalName}': typeof import('${relative(options.buildDir, c.filePath)}')['${c.export}']`).join(',\n')} ${options.components.map(c => ` '${c.pascalName}': typeof import('${relative(options.buildDir, c.filePath)}')['${c.export}']`).join(',\n')}