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

Commit

Permalink
fix: hmr doesn't work when modifying the code of jsx in sfc(#88) (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperBigSniper authored Oct 15, 2021
1 parent 7a6f9e9 commit 66d6485
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/hmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ export async function handleHotUpdate(
const templateModule = modules.find((m) => /type=template/.test(m.url))

if (!isEqualBlock(descriptor.script, prevDescriptor.script)) {
affectedModules.add(mainModule)
let scriptModule: ModuleNode | undefined
if (descriptor.script?.lang && !descriptor.script.src) {
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)) {
Expand Down

0 comments on commit 66d6485

Please sign in to comment.