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,11 +46,13 @@ 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)
}
} else {
nuxt.hook('prepare:types', () => nuxt.close())
}
}
const watchEvents: Record<EventType, 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir'> = {

View File

@ -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
}