perf(vite): avoid endsWith when checking for whitespace (#24746)

This commit is contained in:
Michael Brevard 2024-01-29 13:11:06 +02:00 committed by GitHub
parent b5853c977e
commit 860cfe16b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -119,7 +119,8 @@ export const composableKeysPlugin = createUnplugin((options: ComposableKeysOptio
}
// TODO: Optimize me (https://github.com/nuxt/framework/pull/8529)
const endsWithComma = code.slice(codeIndex + (node as any).start, codeIndex + (node as any).end - 1).trim().endsWith(',')
const newCode = code.slice(codeIndex + (node as any).start, codeIndex + (node as any).end - 1).trim()
const endsWithComma = newCode[newCode.length - 1] === ','
s.appendLeft(
codeIndex + (node as any).end - 1,