perf(nuxt): early return from plugin annotation for non-object syntax plugins

This commit is contained in:
Daniel Roe 2025-01-20 15:15:04 +00:00
parent f458153d9f
commit 8374ef0ba6
No known key found for this signature in database
GPG Key ID: 3714AB03996F442B

View File

@ -44,6 +44,9 @@ export async function extractMetadata (code: string, loader = 'ts' as 'ts' | 'ts
if (metaCache[code]) { if (metaCache[code]) {
return metaCache[code] return metaCache[code]
} }
if (code.match(/defineNuxtPlugin\s*\([\w(]/)) {
return {}
}
const js = await transform(code, { loader }) const js = await transform(code, { loader })
parseAndWalk(js.code, `file.${loader}`, (node) => { parseAndWalk(js.code, `file.${loader}`, (node) => {
if (node.type !== 'CallExpression' || node.callee.type !== 'Identifier') { return } if (node.type !== 'CallExpression' || node.callee.type !== 'Identifier') { return }