diff --git a/packages/plugin-vue/src/handleHotUpdate.ts b/packages/plugin-vue/src/handleHotUpdate.ts index c831785f..a5781a3e 100644 --- a/packages/plugin-vue/src/handleHotUpdate.ts +++ b/packages/plugin-vue/src/handleHotUpdate.ts @@ -31,6 +31,7 @@ export async function handleHotUpdate( { file, modules, read }: HmrContext, options: ResolvedOptions, customElement: boolean, + typeDepModules?: ModuleNode[], ): Promise { const prevDescriptor = getDescriptor(file, options, false, true) if (!prevDescriptor) { @@ -172,7 +173,9 @@ export async function handleHotUpdate( } debug(`[vue:update(${updateType.join('&')})] ${file}`) } - return [...affectedModules].filter(Boolean) as ModuleNode[] + return [...affectedModules, ...(typeDepModules || [])].filter( + Boolean, + ) as ModuleNode[] } export function isEqualBlock(a: SFCBlock | null, b: SFCBlock | null): boolean { diff --git a/packages/plugin-vue/src/index.ts b/packages/plugin-vue/src/index.ts index 477eda57..32e1ddf4 100644 --- a/packages/plugin-vue/src/index.ts +++ b/packages/plugin-vue/src/index.ts @@ -1,5 +1,5 @@ import fs from 'node:fs' -import type { Plugin, ViteDevServer } from 'vite' +import type { ModuleNode, Plugin, ViteDevServer } from 'vite' import { createFilter, normalizePath } from 'vite' import type { SFCBlock, @@ -224,14 +224,22 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin { if (options.value.compiler.invalidateTypeCache) { options.value.compiler.invalidateTypeCache(ctx.file) } + + let typeDepModules: ModuleNode[] | undefined + const matchesFilter = filter.value(ctx.file) if (typeDepToSFCMap.has(ctx.file)) { - return handleTypeDepChange(typeDepToSFCMap.get(ctx.file)!, ctx) + typeDepModules = handleTypeDepChange( + typeDepToSFCMap.get(ctx.file)!, + ctx, + ) + if (!matchesFilter) return typeDepModules } - if (filter.value(ctx.file)) { + if (matchesFilter) { return handleHotUpdate( ctx, options.value, customElementFilter.value(ctx.file), + typeDepModules, ) } }, diff --git a/playground/vue/ExportTypeProps1.vue b/playground/vue/ExportTypeProps1.vue new file mode 100644 index 00000000..29cb1e17 --- /dev/null +++ b/playground/vue/ExportTypeProps1.vue @@ -0,0 +1,19 @@ + + + + + + + diff --git a/playground/vue/ExportTypeProps2.vue b/playground/vue/ExportTypeProps2.vue new file mode 100644 index 00000000..72fa5059 --- /dev/null +++ b/playground/vue/ExportTypeProps2.vue @@ -0,0 +1,8 @@ + + + diff --git a/playground/vue/Main.vue b/playground/vue/Main.vue index b25b54e9..566fec60 100644 --- a/playground/vue/Main.vue +++ b/playground/vue/Main.vue @@ -36,6 +36,8 @@ + +