fix(nuxt): close top-level watcher on nuxt 'close' (#27571)

This commit is contained in:
Daniel Roe 2024-06-12 20:55:24 +01:00 committed by GitHub
parent 803100e34e
commit 6bca120d02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -136,6 +136,7 @@ function createGranularWatcher () {
console.timeEnd('[nuxt] builder:chokidar:watch') console.timeEnd('[nuxt] builder:chokidar:watch')
} }
}) })
nuxt.hook('close', () => watcher?.close())
} }
} }

View File

@ -49,7 +49,10 @@ 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: () => Promise.resolve(hooks.callHook('close', nuxt)), close: async () => {
await hooks.callHook('close', nuxt)
hooks.removeAllHooks()
},
vfs: {}, vfs: {},
apps: {}, apps: {},
} }