Skip to content

Commit

Permalink
fix(plugin-vue): handle custom element when hot update
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Jan 6, 2024
1 parent 8c694f6 commit 6ffee6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/plugin-vue/src/handleHotUpdate.ts
Expand Up @@ -30,6 +30,7 @@ const directRequestRE = /(?:\?|&)direct\b/
export async function handleHotUpdate(
{ file, modules, read }: HmrContext,
options: ResolvedOptions,
customElement: boolean,
): Promise<ModuleNode[] | void> {
const prevDescriptor = getDescriptor(file, options, false, true)
if (!prevDescriptor) {
Expand All @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion packages/plugin-vue/src/index.ts
Expand Up @@ -137,7 +137,11 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin<Api> {
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),
)
}
},

Expand Down

0 comments on commit 6ffee6d

Please sign in to comment.