Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
fix(vite, webpack): generate composable keys based on order (#6191)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Jul 29, 2022
1 parent d4eba42 commit 3f2eb3a
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 @@ -28,6 +28,7 @@ export const composableKeysPlugin = createUnplugin((options: ComposableKeysOptio
const { 0: script = code, index: codeIndex = 0 } = code.match(/(?<=<script[^>]*>)[\S\s.]*?(?=<\/script>)/) || []
const s = new MagicString(code)
// https://github.com/unjs/unplugin/issues/90
let count = 0
const relativeID = isAbsolute(id) ? relative(options.rootDir, id) : id
walk(this.parse(script, {
sourceType: 'module',
Expand All @@ -39,7 +40,7 @@ export const composableKeysPlugin = createUnplugin((options: ComposableKeysOptio
const end = (node as any).end
s.appendLeft(
codeIndex + end - 1,
(node.arguments.length ? ', ' : '') + "'$" + hash(`${relativeID}-${codeIndex + end}`) + "'"
(node.arguments.length ? ', ' : '') + "'$" + hash(`${relativeID}-${++count}`) + "'"
)
}
}
Expand Down

0 comments on commit 3f2eb3a

Please sign in to comment.