mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 15:42:09 +00:00
feat(bridge): generate components declarations (#2174)
This commit is contained in:
parent
ae6f095ee8
commit
8a6db589fe
@ -1,5 +1,6 @@
|
|||||||
import { useNuxt, resolveModule } from '@nuxt/kit'
|
import { useNuxt, resolveModule, addTemplate } from '@nuxt/kit'
|
||||||
import { resolve } from 'pathe'
|
import { resolve } from 'pathe'
|
||||||
|
import { componentsTypeTemplate } from '../../nuxt3/src/components/templates'
|
||||||
import { distDir } from './dirs'
|
import { distDir } from './dirs'
|
||||||
|
|
||||||
export function setupAppBridge (_options: any) {
|
export function setupAppBridge (_options: any) {
|
||||||
@ -17,6 +18,21 @@ export function setupAppBridge (_options: any) {
|
|||||||
nuxt.options.fetch.server = false
|
nuxt.options.fetch.server = false
|
||||||
nuxt.options.fetch.client = false
|
nuxt.options.fetch.client = false
|
||||||
|
|
||||||
|
// Setup types for components
|
||||||
|
const components = []
|
||||||
|
nuxt.hook('components:extend', (registeredComponents) => {
|
||||||
|
components.push(...registeredComponents)
|
||||||
|
})
|
||||||
|
addTemplate({
|
||||||
|
...componentsTypeTemplate,
|
||||||
|
options: { components, buildDir: nuxt.options.buildDir }
|
||||||
|
})
|
||||||
|
nuxt.hook('prepare:types', ({ references }) => {
|
||||||
|
if (components.length) {
|
||||||
|
references.push({ path: resolve(nuxt.options.buildDir, 'components.d.ts') })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Alias vue to have identical vue3 exports
|
// Alias vue to have identical vue3 exports
|
||||||
nuxt.options.alias['vue2-bridge'] = resolve(distDir, 'runtime/vue2-bridge.mjs')
|
nuxt.options.alias['vue2-bridge'] = resolve(distDir, 'runtime/vue2-bridge.mjs')
|
||||||
for (const alias of [
|
for (const alias of [
|
||||||
|
Loading…
Reference in New Issue
Block a user