Skip to content

Commit eb719bf

Browse files
authored
fix: handle HMR for Vue SFC with query parameters (fix #9341) (#10794)
1 parent 34ceb0d commit eb719bf

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/plugin-vue/src/handleHotUpdate.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@ export async function handleHotUpdate(
3333

3434
let needRerender = false
3535
const affectedModules = new Set<ModuleNode | undefined>()
36-
const mainModule = modules.find(
37-
(m) => !/type=/.test(m.url) || /type=script/.test(m.url)
38-
)
36+
const mainModule = modules
37+
.filter((m) => !/type=/.test(m.url) || /type=script/.test(m.url))
38+
// #9341
39+
// We pick the module with the shortest URL in order to pick the module
40+
// with the lowest number of query parameters.
41+
.sort((m1, m2) => {
42+
return m1.url.length - m2.url.length
43+
})[0]
3944
const templateModule = modules.find((m) => /type=template/.test(m.url))
4045

4146
if (hasScriptChanged(prevDescriptor, descriptor)) {

0 commit comments

Comments
 (0)