mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
fix(nuxt): add type support for router composables without pages/
integration
This commit is contained in:
parent
2518cf8d37
commit
397c54c9db
@ -64,6 +64,14 @@ export default defineNuxtModule({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// adds support for #vue-router alias (used for types) with and without pages integration
|
||||||
|
addTemplate({
|
||||||
|
filename: 'vue-router.d.ts',
|
||||||
|
getContents: () => `export * from '${useExperimentalTypedPages ? 'vue-router/auto' : 'vue-router'}'`
|
||||||
|
})
|
||||||
|
|
||||||
|
nuxt.options.alias['#vue-router'] = join(nuxt.options.buildDir, 'vue-router')
|
||||||
|
|
||||||
if (!nuxt.options.pages) {
|
if (!nuxt.options.pages) {
|
||||||
addPlugin(resolve(distDir, 'app/plugins/router'))
|
addPlugin(resolve(distDir, 'app/plugins/router'))
|
||||||
addTemplate({
|
addTemplate({
|
||||||
@ -78,6 +86,12 @@ export default defineNuxtModule({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addTemplate({
|
||||||
|
filename: 'vue-router.mjs',
|
||||||
|
// TODO: use `vue-router/auto` when we have support for page metadata
|
||||||
|
getContents: () => 'export * from \'vue-router\';'
|
||||||
|
})
|
||||||
|
|
||||||
if (useExperimentalTypedPages) {
|
if (useExperimentalTypedPages) {
|
||||||
const declarationFile = './types/typed-router.d.ts'
|
const declarationFile = './types/typed-router.d.ts'
|
||||||
|
|
||||||
@ -261,17 +275,6 @@ export default defineNuxtModule({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// adds support for #vue-router alias
|
|
||||||
addTemplate({
|
|
||||||
filename: 'vue-router.mjs',
|
|
||||||
// TODO: use `vue-router/auto` when we have support for page metadata
|
|
||||||
getContents: () => 'export * from \'vue-router\';'
|
|
||||||
})
|
|
||||||
addTemplate({
|
|
||||||
filename: 'vue-router.d.ts',
|
|
||||||
getContents: () => `export * from '${useExperimentalTypedPages ? 'vue-router/auto' : 'vue-router'}'`
|
|
||||||
})
|
|
||||||
|
|
||||||
// Add routes template
|
// Add routes template
|
||||||
addTemplate({
|
addTemplate({
|
||||||
filename: 'routes.mjs',
|
filename: 'routes.mjs',
|
||||||
@ -365,8 +368,6 @@ export default defineNuxtModule({
|
|||||||
filePath: resolve(distDir, 'pages/runtime/page')
|
filePath: resolve(distDir, 'pages/runtime/page')
|
||||||
})
|
})
|
||||||
|
|
||||||
nuxt.options.alias['#vue-router'] = join(nuxt.options.buildDir, 'vue-router')
|
|
||||||
|
|
||||||
// Add declarations for middleware keys
|
// Add declarations for middleware keys
|
||||||
nuxt.hook('prepare:types', ({ references }) => {
|
nuxt.hook('prepare:types', ({ references }) => {
|
||||||
references.push({ path: resolve(nuxt.options.buildDir, 'types/middleware.d.ts') })
|
references.push({ path: resolve(nuxt.options.buildDir, 'types/middleware.d.ts') })
|
||||||
|
Loading…
Reference in New Issue
Block a user