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

Commit 3f2eb3a

Browse files
authored
fix(vite, webpack): generate composable keys based on order (#6191)
1 parent d4eba42 commit 3f2eb3a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/vite/src/plugins/composable-keys.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const composableKeysPlugin = createUnplugin((options: ComposableKeysOptio
2828
const { 0: script = code, index: codeIndex = 0 } = code.match(/(?<=<script[^>]*>)[\S\s.]*?(?=<\/script>)/) || []
2929
const s = new MagicString(code)
3030
// https://github.com/unjs/unplugin/issues/90
31+
let count = 0
3132
const relativeID = isAbsolute(id) ? relative(options.rootDir, id) : id
3233
walk(this.parse(script, {
3334
sourceType: 'module',
@@ -39,7 +40,7 @@ export const composableKeysPlugin = createUnplugin((options: ComposableKeysOptio
3940
const end = (node as any).end
4041
s.appendLeft(
4142
codeIndex + end - 1,
42-
(node.arguments.length ? ', ' : '') + "'$" + hash(`${relativeID}-${codeIndex + end}`) + "'"
43+
(node.arguments.length ? ', ' : '') + "'$" + hash(`${relativeID}-${++count}`) + "'"
4344
)
4445
}
4546
}

0 commit comments

Comments
 (0)