diff --git a/packages/vite/src/plugins/composable-keys.ts b/packages/vite/src/plugins/composable-keys.ts index af251194fe1..1b649363c0d 100644 --- a/packages/vite/src/plugins/composable-keys.ts +++ b/packages/vite/src/plugins/composable-keys.ts @@ -59,9 +59,12 @@ export const composableKeysPlugin = createUnplugin((options: ComposableKeysOptio break } + // 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(',') + s.appendLeft( codeIndex + (node as any).end - 1, - (node.arguments.length ? ', ' : '') + "'$" + hash(`${relativeID}-${++count}`) + "'" + (node.arguments.length && !endsWithComma ? ', ' : '') + "'$" + hash(`${relativeID}-${++count}`) + "'" ) } })