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
sxzz committed Jan 6, 2024

Verified

This commit was signed with the committer’s verified signature.
mayeut Matthieu Darbois
1 parent 8c694f6 commit 6ffee6d
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/plugin-vue/src/handleHotUpdate.ts
Original file line number Diff line number Diff line change
@@ -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) {
@@ -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)
6 changes: 5 additions & 1 deletion packages/plugin-vue/src/index.ts
Original file line number Diff line number Diff line change
@@ -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),
)
}
},

0 comments on commit 6ffee6d

Please sign in to comment.