mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 07:32:01 +00:00
fix(vite, webpack): generate composable keys based on order (#6191)
This commit is contained in:
parent
d4eba42f17
commit
3f2eb3a3b1
@ -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',
|
||||
@ -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}`) + "'"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user