fix(kit): handle node 14 performance behaviour (#19733)

This commit is contained in:
Daniel Roe 2023-03-17 10:08:21 +00:00 committed by GitHub
parent 40ad3f799b
commit 81da4cf5a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,8 +71,8 @@ export function defineNuxtModule<OptionsT extends ModuleOptions> (definition: Mo
const key = `nuxt:module:${uniqueKey || (Math.round(Math.random() * 10000))}`
const mark = performance.mark(key)
const res = await definition.setup?.call(null as any, _options, nuxt) ?? {}
const perf = performance.measure(key, mark.name)
const setupTime = Math.round((perf.duration * 100)) / 100
const perf = performance.measure(key, mark?.name) // TODO: remove when Node 14 reaches EOL
const setupTime = perf ? Math.round((perf.duration * 100)) / 100 : 0 // TODO: remove when Node 14 reaches EOL
// Measure setup time
if (setupTime > 5000) {