fix(nuxt): unregister hooks the moment close is called (#27637)

This commit is contained in:
Daniel Roe 2024-06-15 22:52:04 +01:00 committed by GitHub
parent cec299bdc4
commit fda6cf7838
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 7 deletions

View File

@ -46,10 +46,12 @@ export async function build (nuxt: Nuxt) {
if (!nuxt.options._prepare) { if (!nuxt.options._prepare) {
await Promise.all([checkForExternalConfigurationFiles(), bundle(nuxt)]) await Promise.all([checkForExternalConfigurationFiles(), bundle(nuxt)])
await nuxt.callHook('build:done') await nuxt.callHook('build:done')
}
if (!nuxt.options.dev) { if (!nuxt.options.dev) {
await nuxt.callHook('close', nuxt) await nuxt.callHook('close', nuxt)
}
} else {
nuxt.hook('prepare:types', () => nuxt.close())
} }
} }

View File

@ -49,14 +49,13 @@ export function createNuxt (options: NuxtOptions): Nuxt {
addHooks: hooks.addHooks, addHooks: hooks.addHooks,
hook: hooks.hook, hook: hooks.hook,
ready: () => initNuxt(nuxt), ready: () => initNuxt(nuxt),
close: async () => { close: () => hooks.callHook('close', nuxt),
await hooks.callHook('close', nuxt)
hooks.removeAllHooks()
},
vfs: {}, vfs: {},
apps: {}, apps: {},
} }
hooks.hookOnce('close', () => { hooks.removeAllHooks() })
return nuxt return nuxt
} }