New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: hmr doesn't work when modifying the code of jsx in sfc #4563
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<script lang="jsx"> | ||
import { defineComponent, ref } from 'vue' | ||
|
||
export default defineComponent(() => { | ||
const count = ref(4) | ||
const inc = () => count.value++ | ||
|
||
return () => ( | ||
<button class="script" onClick={inc}> | ||
script {count.value} | ||
</button> | ||
) | ||
}) | ||
</script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineComponent, ref } from 'vue' | ||
|
||
export default defineComponent(() => { | ||
const count = ref(5) | ||
const inc = () => count.value++ | ||
|
||
return () => ( | ||
<button class="src-import" onClick={inc}> | ||
src import {count.value} | ||
</button> | ||
) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<script src="./SrcImport.jsx"></script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,14 @@ export async function handleHotUpdate({ | |
!isEqualBlock(descriptor.script, prevDescriptor.script) || | ||
!isEqualBlock(descriptor.scriptSetup, prevDescriptor.scriptSetup) | ||
) { | ||
affectedModules.add(mainModule) | ||
let scriptModule | ||
if (descriptor.script?.lang && !descriptor.script.src) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this is not necessary to fix the case once Is it correct that this is added only to handle the case where user or other plugins use HMR API inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's to handle the case where |
||
const scriptModuleRE = new RegExp( | ||
`type=script.*&lang\.${descriptor.script.lang}$` | ||
) | ||
scriptModule = modules.find((m) => scriptModuleRE.test(m.url)) | ||
} | ||
affectedModules.add(scriptModule || mainModule) | ||
} | ||
|
||
if (!isEqualBlock(descriptor.template, prevDescriptor.template)) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
floating variables should be defined with a typedef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review, I will change it.