fix(nuxt3): hotfix for missing components declaration (#2949)

This commit is contained in:
Daniel Roe 2022-01-27 12:46:28 +00:00 committed by GitHub
parent 965f2abaee
commit d20b672546
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,6 +65,12 @@ export default defineNuxtModule<ComponentsOptions>({
nuxt.hook('app:templates', async (app) => { nuxt.hook('app:templates', async (app) => {
components = await scanComponents(componentDirs, nuxt.options.srcDir!) components = await scanComponents(componentDirs, nuxt.options.srcDir!)
await nuxt.callHook('components:extend', components) await nuxt.callHook('components:extend', components)
app.templates.push({
...componentsTypeTemplate,
options: { components, buildDir: nuxt.options.buildDir }
})
if (!components.length) { if (!components.length) {
return return
} }
@ -74,18 +80,11 @@ export default defineNuxtModule<ComponentsOptions>({
options: { components } options: { components }
}) })
app.templates.push({
...componentsTypeTemplate,
options: { components, buildDir: nuxt.options.buildDir }
})
app.plugins.push({ src: '#build/components' }) app.plugins.push({ src: '#build/components' })
}) })
nuxt.hook('prepare:types', ({ references }) => { nuxt.hook('prepare:types', ({ references }) => {
if (components.length) {
references.push({ path: resolve(nuxt.options.buildDir, 'components.d.ts') }) references.push({ path: resolve(nuxt.options.buildDir, 'components.d.ts') })
}
}) })
// Watch for changes // Watch for changes