From 66d648574e634c962ecd38e2ac919c485bff74a6 Mon Sep 17 00:00:00 2001 From: SuperBigSniper <844489544@qq.com> Date: Sat, 16 Oct 2021 01:41:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20hmr=20doesn't=20work=20when=20modifying?= =?UTF-8?q?=20the=20code=20of=20jsx=20in=20sfc=EF=BC=88#88=EF=BC=89=20(#13?= =?UTF-8?q?7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hmr.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/hmr.ts b/src/hmr.ts index 1b06e31..db6d7bc 100644 --- a/src/hmr.ts +++ b/src/hmr.ts @@ -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)) {