mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
refactor(nitro): expose writeTypes
and call this within builder:generateApp
(#2413)
This commit is contained in:
parent
639e49be27
commit
a1a2d2f92b
@ -3,7 +3,7 @@ import fetch from 'node-fetch'
|
||||
import { addPluginTemplate, useNuxt } from '@nuxt/kit'
|
||||
import { stringifyQuery } from 'ufo'
|
||||
import { resolve } from 'pathe'
|
||||
import { build, generate, prepare, getNitroContext, NitroContext, createDevServer, wpfs, resolveMiddleware } from '@nuxt/nitro'
|
||||
import { build, generate, prepare, getNitroContext, NitroContext, createDevServer, wpfs, resolveMiddleware, scanMiddleware, writeTypes } from '@nuxt/nitro'
|
||||
import { AsyncLoadingPlugin } from './async-loading'
|
||||
import { distDir } from './dirs'
|
||||
|
||||
@ -128,6 +128,12 @@ export function setupNitroBridge () {
|
||||
opts.references.push({ path: resolve(nuxt.options.buildDir, 'nitro.d.ts') })
|
||||
})
|
||||
|
||||
// nuxt prepare
|
||||
nuxt.hook('builder:generateApp', async () => {
|
||||
nitroDevContext.scannedMiddleware = await scanMiddleware(nitroDevContext._nuxt.serverDir)
|
||||
await writeTypes(nitroDevContext)
|
||||
})
|
||||
|
||||
// nuxt build/dev
|
||||
// @ts-ignore
|
||||
nuxt.options.build._minifyServer = false
|
||||
@ -142,7 +148,7 @@ export function setupNitroBridge () {
|
||||
}
|
||||
})
|
||||
|
||||
// nude dev
|
||||
// nuxt dev
|
||||
if (nuxt.options.dev) {
|
||||
nitroDevContext._internal.hooks.hook('nitro:compiled', () => { nuxt.server.watch() })
|
||||
nuxt.hook('build:compile', ({ compiler }) => { compiler.outputFileSystem = wpfs })
|
||||
|
@ -64,7 +64,7 @@ export async function build (nitroContext: NitroContext) {
|
||||
return nitroContext._nuxt.dev ? _watch(nitroContext) : _build(nitroContext)
|
||||
}
|
||||
|
||||
async function writeTypes (nitroContext: NitroContext) {
|
||||
export async function writeTypes (nitroContext: NitroContext) {
|
||||
const routeTypes: Record<string, string[]> = {}
|
||||
|
||||
const middleware = [
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { resolve } from 'pathe'
|
||||
import { wpfs, getNitroContext, createDevServer, resolveMiddleware, build, prepare, generate } from '@nuxt/nitro'
|
||||
import { wpfs, getNitroContext, createDevServer, resolveMiddleware, build, prepare, generate, writeTypes, scanMiddleware } from '@nuxt/nitro'
|
||||
import type { Nuxt } from '@nuxt/schema'
|
||||
|
||||
export function initNitro (nuxt: Nuxt) {
|
||||
@ -63,6 +63,11 @@ export function initNitro (nuxt: Nuxt) {
|
||||
}
|
||||
})
|
||||
|
||||
nuxt.hook('builder:generateApp', async () => {
|
||||
nitroDevContext.scannedMiddleware = await scanMiddleware(nitroDevContext._nuxt.serverDir)
|
||||
await writeTypes(nitroDevContext)
|
||||
})
|
||||
|
||||
// nuxt dev
|
||||
if (nuxt.options.dev) {
|
||||
nitroDevContext._internal.hooks.hook('nitro:compiled', () => { nuxt.server.watch() })
|
||||
|
Loading…
Reference in New Issue
Block a user