Skip to content

Commit

Permalink
perf(vite): avoid endsWith when checking for whitespace (#24746)
Browse files Browse the repository at this point in the history
  • Loading branch information
GalacticHypernova committed Jan 29, 2024
1 parent b5853c9 commit 860cfe1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/vite/src/plugins/composable-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 860cfe1

Please sign in to comment.