diff --git a/packages/nuxt/src/core/builder.ts b/packages/nuxt/src/core/builder.ts index ca1b41dfd7..354829a28f 100644 --- a/packages/nuxt/src/core/builder.ts +++ b/packages/nuxt/src/core/builder.ts @@ -46,10 +46,12 @@ export async function build (nuxt: Nuxt) { if (!nuxt.options._prepare) { await Promise.all([checkForExternalConfigurationFiles(), bundle(nuxt)]) await nuxt.callHook('build:done') - } - if (!nuxt.options.dev) { - await nuxt.callHook('close', nuxt) + if (!nuxt.options.dev) { + await nuxt.callHook('close', nuxt) + } + } else { + nuxt.hook('prepare:types', () => nuxt.close()) } } diff --git a/packages/nuxt/src/core/nuxt.ts b/packages/nuxt/src/core/nuxt.ts index f70106a4f1..319324935c 100644 --- a/packages/nuxt/src/core/nuxt.ts +++ b/packages/nuxt/src/core/nuxt.ts @@ -49,14 +49,13 @@ export function createNuxt (options: NuxtOptions): Nuxt { addHooks: hooks.addHooks, hook: hooks.hook, ready: () => initNuxt(nuxt), - close: async () => { - await hooks.callHook('close', nuxt) - hooks.removeAllHooks() - }, + close: () => hooks.callHook('close', nuxt), vfs: {}, apps: {}, } + hooks.hookOnce('close', () => { hooks.removeAllHooks() }) + return nuxt }