From 6ffee6d09bde5a7738c91df2a84e9fb2338766a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Sun, 7 Jan 2024 04:07:19 +0800 Subject: [PATCH] fix(plugin-vue): handle custom element when hot update --- packages/plugin-vue/src/handleHotUpdate.ts | 3 ++- packages/plugin-vue/src/index.ts | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/plugin-vue/src/handleHotUpdate.ts b/packages/plugin-vue/src/handleHotUpdate.ts index 233c8d89..f6fc455e 100644 --- a/packages/plugin-vue/src/handleHotUpdate.ts +++ b/packages/plugin-vue/src/handleHotUpdate.ts @@ -30,6 +30,7 @@ const directRequestRE = /(?:\?|&)direct\b/ export async function handleHotUpdate( { file, modules, read }: HmrContext, options: ResolvedOptions, + customElement: boolean, ): Promise { const prevDescriptor = getDescriptor(file, options, false, true) if (!prevDescriptor) { @@ -46,7 +47,7 @@ export async function handleHotUpdate( const templateModule = modules.find((m) => /type=template/.test(m.url)) // trigger resolveScript for descriptor so that we'll have the AST ready - resolveScript(descriptor, options, false) + resolveScript(descriptor, options, false, customElement) const scriptChanged = hasScriptChanged(prevDescriptor, descriptor) if (scriptChanged) { affectedModules.add(getScriptModule(modules) || mainModule) diff --git a/packages/plugin-vue/src/index.ts b/packages/plugin-vue/src/index.ts index 3db40338..44b7d785 100644 --- a/packages/plugin-vue/src/index.ts +++ b/packages/plugin-vue/src/index.ts @@ -137,7 +137,11 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin { return handleTypeDepChange(typeDepToSFCMap.get(ctx.file)!, ctx) } if (filter.value(ctx.file)) { - return handleHotUpdate(ctx, options.value) + return handleHotUpdate( + ctx, + options.value, + customElementFilter.value(ctx.file), + ) } },